我有一个自定义 ARM 模板,它部署了一个带有子 EventHub 的 EventHub 命名空间,该子 EventHub 又具有两个 AuthorizationRules 和一个 ConsumerGroup 作为子级。验证通过,但我收到部署错误。似乎 Azure 资源管理器首先尝试在命名空间存在之前部署授权规则,即使我添加了所需的“dependsOn”属性,但随后部署从头到尾进行并成功部署了每个资源。如果我只从门户部署它可能是可以容忍的,但是当我以编程方式部署此模板时,即使部署“成功”并且我的回滚机制触发,我也会收到错误消息。
以下是门户网站给出的错误链接:
这是我的 ARM 模板(评论只是为了帮助您找到资源):
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namespaceName": {
"type": "string"
},
"eventHubName": {
"type": "string"
}
},
"variables": {
"SharedAccessKeyName": "Event-Dispatcher-Send-Access-Key",
"ReadOnlySharedAccessKeyName": "Plugin-Listen-Access-Key",
"ConsumerGroup": "plugin"
},
"resources": [
{
// Event Hub Namespace
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2018-01-01-preview",
"name": "[parameters('namespaceName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 1
},
"properties": {
"zoneRedundant": false,
"isAutoInflateEnabled": false,
"maximumThroughputUnits": 0,
"kafkaEnabled": true
},
"resources": [
{
// Event Hub
"name": "[concat(parameters('namespaceName'), '/', parameters('eventHubName'))]",
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"properties": {
"messageRetention": 1
},
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]"
],
"resources": [
{
// Shared Access Key
"name": "[concat(parameters('namespaceName'), '/', parameters('eventHubName'), '/', variables('SharedAccessKeyName'))]",
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "2017-04-01",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]",
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', parameters('namespaceName'), parameters('eventHubName'))]"
],
"properties": {
"rights": [
"Send",
"Listen"
]
}
},
{
// Read-only Shared Access Key
"name": "[concat(parameters('namespaceName'), '/', parameters('eventHubName'), '/', variables('ReadOnlySharedAccessKeyName'))]",
"type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
"apiVersion": "2017-04-01",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]",
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', parameters('namespaceName'), parameters('eventHubName'))]"
],
"properties": {
"rights": [
"Listen"
]
}
},
{
// Consumer Groups
"name": "[concat(parameters('namespaceName'), '/', parameters('eventHubName'), '/', variables('ConsumerGroup'))]",
"type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
"apiVersion": "2017-04-01",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]",
"[resourceId('Microsoft.EventHub/namespaces/eventhubs', parameters('namespaceName'), parameters('eventHubName'))]"
],
"properties": {}
}
]
}
]
}
],
"outputs": {
"SharedAccessKey": {
"type": "string",
"value": "[listKeys(concat(parameters('namespaceName'), '/', parameters('eventHubName'), '/', variables('SharedAccessKeyName')), '2017-04-01').primaryKey.value]"
},
"SharedAccessKeyName": {
"type": "string",
"value": "[variables('SharedAccessKeyName')]"
},
"ReadOnlySharedAccessKey": {
"type": "string",
"value": "[listKeys(concat(parameters('namespaceName'), '/', parameters('eventHubName'), '/', variables('ReadOnlySharedAccessKeyName')), '2017-04-01').primaryKey.value]"
},
"ReadOnlySharedAccessKeyName": {
"type": "string",
"value": "[variables('ReadOnlySharedAccessKeyName')]"
},
"ConsumerGroup": {
"type": "string",
"value": "[variables('ConsumerGroup')]"
}
}
}
谢谢你。