找不到ARM模板部署资源命名空间



我有一个自定义的ARM模板,它部署了一个带有子EventHub的EventHub命名空间,该命名空间又有两个AuthorizationRules和一个ConsumerGroup作为子级。验证通过了,但我得到了一个部署错误。Azure资源管理器似乎在命名空间存在之前就开始尝试部署授权规则,尽管我添加了所需的"dependensOn"属性,但随后部署从头至尾,并成功部署了每个资源。如果我只从门户部署它,这是可以容忍的,但当我以编程方式部署此模板时,即使部署"成功"并且触发了回滚机制,我也会收到错误。

以下是门户网站给出的错误链接:

部署步骤

错误消息

这是我的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')]"
}
}
}

谢谢。

下面的例子与您的需求类似,我已经测试了这个模板,它运行良好。所以你可以根据这个例子修改你的模板,让它发挥作用。

{
"$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]"
}
}
}

最新更新