Ниже приведен пример, аналогичный вашим требованиям, и я протестировал этот шаблон, и он работает нормально. Таким образом, вы можете изменить свой шаблон в соответствии с этим примером и заставить его работать.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namespaceName": {
"type": "String",
"metadata": {
"description": "Name of EventHub namespace"
}
},
"namespaceAuthorizationRuleName": {
"type": "String",
"metadata": {
"description": "Name of Namespace Authorization Rule"
}
},
"isAutoInflateEnabled": {
"defaultValue": "True",
"allowedValues": [
"True",
"False"
],
"type": "String",
"metadata": {
"description": "Enable or disable AutoInflate"
}
},
"maximumThroughputUnits": {
"defaultValue": 0,
"minValue": 0,
"maxValue": 20,
"type": "Int",
"metadata": {
"description": "Enable or disable AutoInflate"
}
},
"eventHubName": {
"type": "String",
"metadata": {
"description": "Name of Event Hub"
}
},
"eventhubAuthorizationRuleName": {
"type": "String",
"metadata": {
"description": "Name of Eventhub Authorization Rule"
}
},
"eventhubAuthorizationRuleName1": {
"type": "String",
"metadata": {
"description": "Name of Eventhub Authorization Rule"
}
},
"consumerGroupName": {
"type": "String",
"metadata": {
"description": "Name of Consumer Group"
}
},
"messageRetentionInDays": {
"defaultValue": 1,
"minValue": 1,
"maxValue": 7,
"type": "Int",
"metadata": {
"description": "How long to retain the data in Event Hub"
}
},
"partitionCount": {
"defaultValue": 4,
"minValue": 2,
"maxValue": 32,
"type": "Int",
"metadata": {
"description": "Number of partitions chosen"
}
},
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "String",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"defaultSASKeyName": "RootManageSharedAccessKey",
"authRuleResourceId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', parameters('namespaceName'), variables('defaultSASKeyName'))]",
"nsAuthorizationRuleId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', parameters('namespaceName'), parameters('namespaceAuthorizationRuleName'))]",
"ehAuthorizationRuleId1": "[resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('namespaceName'),parameters('eventHubName'), parameters('eventhubAuthorizationRuleName'))]",
"ehAuthorizationRuleId2": "[resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', parameters('namespaceName'),parameters('eventHubName'), parameters('eventhubAuthorizationRuleName1'))]"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2017-04-01",
"name": "[parameters('namespaceName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard"
},
"properties": {
"isAutoInflateEnabled": true,
"maximumThroughputUnits": 7
},
"resources": [
{
"type": "eventhubs",
"apiVersion": "2017-04-01",
"name": "[parameters('eventHubName')]",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
],
"properties": {
"messageRetentionInDays": 4,
"partitionCount": 4
},
"resources": [
{
"type": "consumergroups",
"apiVersion": "2017-04-01",
"name": "[parameters('consumerGroupName')]",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'),'/eventhubs/',parameters('eventHubName'))]"
],
"properties": {
"userMetadata": "User Metadata"
}
},
{
"type": "authorizationRules",
"apiVersion": "2017-04-01",
"name": "[parameters('eventhubAuthorizationRuleName')]",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'),'/eventhubs/',parameters('eventHubName'))]"
],
"properties": {
"rights": [
"Send",
"Listen",
"Manage"
]
}
},
{
"type": "authorizationRules",
"apiVersion": "2017-04-01",
"name": "[parameters('eventhubAuthorizationRuleName1')]",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'),'/eventhubs/',parameters('eventHubName'))]"
],
"properties": {
"rights": [
"Send"
]
}
}
]
}
]
},
{
"type": "Microsoft.EventHub/namespaces/AuthorizationRules",
"apiVersion": "2017-04-01",
"name": "[concat(parameters('namespaceName'), '/', parameters('namespaceAuthorizationRuleName'))]",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
],
"properties": {
"rights": [
"Send",
"Listen",
"Manage"
]
}
}
],
"outputs": {
"defaultNamespaceConnectionString": {
"type": "String",
"value": "[listkeys(variables('authRuleResourceId'), '2017-04-01').primaryConnectionString]"
},
"defaultSharedAccessPolicyPrimaryKey": {
"type": "String",
"value": "[listkeys(variables('authRuleResourceId'), '2017-04-01').primaryKey]"
},
"NamespaceConnectionString": {
"type": "String",
"value": "[listkeys(variables('nsAuthorizationRuleId'), '2017-04-01').primaryConnectionString]"
},
"SharedAccessPolicyPrimaryKey": {
"type": "String",
"value": "[listkeys(variables('nsAuthorizationRuleId'), '2017-04-01').primaryKey]"
},
"EventHubConnectionString": {
"type": "String",
"value": "[listkeys(variables('ehAuthorizationRuleId1'), '2017-04-01').primaryConnectionString]"
},
"EventHubSharedAccessPolicyPrimaryKey": {
"type": "String",
"value": "[listkeys(variables('ehAuthorizationRuleId1'), '2017-04-01').primaryKey]"
},
"EventHub1ConnectionString": {
"type": "String",
"value": "[listkeys(variables('ehAuthorizationRuleId2'), '2017-04-01').primaryConnectionString]"
},
"EventHub1SharedAccessPolicyPrimaryKey": {
"type": "String",
"value": "[listkeys(variables('ehAuthorizationRuleId2'), '2017-04-01').primaryKey]"
}
}
}