My ARM template is defined as followed
{
"type": "Microsoft.EventHub/namespaces",
"sku": {
"name": "[parameters('SkuName')]",
"tier": "[parameters('SkuTier')]",
"capacity": "[parameters('SkuCapacity')]"
},
"name": "[parameters('EventHubNamespaceName')]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"properties": {
"isAutoInflateEnabled": false,
"maximumThroughputUnits": 0
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"name": "[concat(parameters('EventHubNamespaceName'), '/', parameters('Eventhubs')[copyIndex('eventsCopy')].name)]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 2,
"status": "Active"
},
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('EventHubNamespaceName'))]"
],
"resources": [
{
"type": "authorizationRules",
"name": "[parameters('Eventhubs')[copyIndex('eventsCopy')].authorizationrulesName]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"rights": [
"Manage",
"Listen",
"Send"
]
},
"dependsOn": [
"[parameters('Eventhubs')[copyIndex('eventsCopy')].name]"
]
}
],
"copy": {
"name": "eventsCopy",
"count": "[length(parameters('Eventhubs'))]",
"mode": "serial"
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
"name": "[concat(parameters('EventHubNamespaceName'), '/', parameters('ConsumerGroups')[copyIndex('ConsumerGroupCopy')].EventhubName, '/', parameters('ConsumerGroups')[copyIndex('ConsumerGroupCopy')].ConsumerGroupName )]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
},
"dependsOn": [
],
"copy": {
"name": "ConsumerGroupCopy",
"count": "[length(parameters('ConsumerGroups'))]",
"mode": "serial"
}
},
With this parameter values
"EventHubNamespaceName": {
"value": "eventhubnamespace"
},
"Eventhubs": {
"value": [
{
"name": "connectionhub",
"authorizationrulesName": "power"
},
{
"name": "devicehub",
"authorizationrulesName": "power"
},
{
"name": "inputdata",
"authorizationrulesName": "power"
}
]
},
"ConsumerGroups": {
"value": [
{
"EventhubName": "connectionhub",
"ConsumerGroupName": "$Default"
},
{
"EventhubName": "devicehub",
"ConsumerGroupName": "$Default"
},
{
"EventhubName": "devicehub",
"ConsumerGroupName": "device"
},
{
"EventhubName": "inputdata",
"ConsumerGroupName": "$Default"
}
]
},
And this fails with the following error
Deployment template validation failed: 'The template resource 'Microsoft.EventHub/namespaces/eventhubnamespace/eventhubs/devicehub/consumergroups/$Default' cannot reference itself. Please see https://aka.ms/arm-template-expressions/#reference for usage details.'.
The error tries to tell that the consumergroups reference themself somehow (I think through the depends on) but I can't see where it reference itself.
The reason I defines consumergroups inside another resource is because I want to create multiple consumergroups and think a nested copy is not possible through ARM.
Does anyone see where I've missed the reference of the same resource inside the same resource Group ?