簡體   English   中英

在具有多個身份驗證規則的多個區域中創建事件中心時,ARM 模板失敗

[英]ARM template fails when creating event hub in multiple regions with multiple auth rules

我有一個 ARM 模板,它在兩個區域(eastus 和 westus2)中創建事件中心命名空間,具有事件中心和多個身份驗證規則(在偶數中心)。 這一直工作到 2020 年 11 月 16 日下午 12:00。 手臂模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {    
    "location-region1": {
      "type": "string",
      "defaultValue": "eastus",
      "metadata": {
        "description": "Name of an azure region"
      }
    },
    "location-region2": {
      "type": "string",
      "defaultValue": "westus2",
      "metadata": {
        "description": "Name of an Azure region"
      }
    },   
    "appName": {
      "type": "string",
      "defaultValue": "jklm",
      "metadata": {
        "description": "Short name of the app or service"
      }
    },
    "uniqueSuffix": {
      "type": "string",
      "defaultValue": "tst",
      "metadata": {
        "description": "Unique Suffix to use for the azure resources of the app or service"
      }
    },
    "environment": {
      "type": "string",
      "defaultValue": "int",
      "allowedValues": [
        "poc",
        "dev",
        "int",
        "uat",
        "prod"
      ],
      "metadata": {
        "description": "The name of the environment"
      }
    },   
    "progressRecordsEventHubName": {
      "type": "string",
      "defaultValue": "progressrecords"
    }
  },
  "variables": {    
    "eventHubNMApiVersion": "2018-01-01-preview",
    "eventHubApiVersion": "2017-04-01",    
    "parentResourceGroupName": "[resourceGroup().name]",
    "regionCount": 2,  
    "location": [
      "[parameters('location-region1')]",
      "[parameters('location-region2')]"
    ],
   
    "appName": "[concat(parameters('appName'),'-',parameters('uniqueSuffix'),'-')]",
   
    "copy": [
      {
        "name": "regionSuffix",
        "count": "[variables('regionCount')]",
        "input": "[concat('r',copyIndex('regionSuffix',1))]"
      },
      {
        "name": "eventHubName",
        "count": "[variables('regionCount')]",
        "input": "[concat(variables('appName'),'ehub-',variables('regionSuffix')[copyIndex('eventHubName')],'-',parameters('environment'))]"
      }
    ]
  },
  "resources": [
   
    {
      "type": "Microsoft.EventHub/namespaces",
      "apiVersion": "[variables('eventHubNMApiVersion')]",
      "name": "[variables('eventHubName')[copyIndex()]]",
      "copy": {
        "name": "resourceLoop",
        "count": "[variables('regionCount')]"
      },
      "location": "[variables('location')[copyIndex()]]",
      "sku": {
        "name": "Standard",
        "tier": "Standard",
        "capacity": 1
      },
      "properties": {
        "zoneRedundant": false,
        "isAutoInflateEnabled": true,
        "maximumThroughputUnits": 1,
        "kafkaEnabled": true
      },
      "resources": [
        {
          "type": "Microsoft.EventHub/namespaces/eventhubs",
          "apiVersion": "[variables('eventHubApiVersion')]",
          "name": "[concat(variables('eventHubName')[copyIndex()], '/',parameters('progressRecordsEventHubName'))]",
          "location": "[variables('location')[copyIndex()]]",
          "dependsOn": [
            "[resourceId('Microsoft.EventHub/namespaces', variables('eventHubName')[copyIndex()])]"
          ],
          "properties": {
            "messageRetentionInDays": 3,
            "partitionCount": 1,
            "status": "Active"
          },
          "resources": [
            {
              "type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
              "apiVersion": "[variables('eventHubApiVersion')]",
              "name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
              "location": "[variables('location')[copyIndex()]]",
              "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
              ],
              "properties": {
                "rights": [
                  "Listen"
                ]
              }
            },
            {
              "type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
              "apiVersion": "[variables('eventHubApiVersion')]",
              "name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Send')]",
              "location": "[variables('location')[copyIndex()]]",
              "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()], parameters('progressRecordsEventHubName'))]"
              ],
              "properties": {
                "rights": [
                  "Send"
                ]
              }
            }
          ]
        }
      ]
    }      
  ],
  "functions": [    
  ],
  "outputs": {}
}

現在,當我運行Test-AzureRmResourceGroupDeployment時,此模板失敗(添加-Debug以查看實際錯誤)錯誤:

Test-AzureRmResourceGroupDeployment : Encountered internal server error. Diagnostic information: timestamp '20201119T072227Z' ......

經過一些故障排除后,我發現刪除模板中的第二個身份驗證規則可以解決問題。 我實際上需要 1 個以上的身份驗證規則。 什么可能導致上述模板失敗? 我似乎找不到任何問題。 您可以在下面找到成功的模板 - 在事件中心有 1 個身份驗證規則

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {    
    "location-region1": {
      "type": "string",
      "defaultValue": "eastus"
    },
    "location-region2": {
      "type": "string",
      "defaultValue": "westus2"
    },   
    "appName": {
      "type": "string",
      "defaultValue": "jklm",
      "metadata": {
        "description": "Short name of the app or service"
      }
    },
    "uniqueSuffix": {
      "type": "string",
      "defaultValue": "tst",
      "metadata": {
        "description": "Unique Suffix to use for the azure resources of the app or service"
      }
    },
    "environment": {
      "type": "string",
      "defaultValue": "int",
      "allowedValues": [
        "poc",
        "dev",
        "int",
        "uat",
        "prod"
      ],
      "metadata": {
        "description": "The name of the environment"
      }
    },   
    "progressRecordsEventHubName": {
      "type": "string",
      "defaultValue": "progressrecords"
    }
  },
  "variables": {    
    "eventHubNMApiVersion": "2018-01-01-preview",
    "eventHubApiVersion": "2017-04-01",    
    "parentResourceGroupName": "[resourceGroup().name]",
    "regionCount": 2,  
    "location": [
      "[parameters('location-region1')]",
      "[parameters('location-region2')]"
    ],   
    "appName": "[concat(parameters('appName'),'-',parameters('uniqueSuffix'),'-')]",   
    "copy": [
      {
        "name": "regionSuffix",
        "count": "[variables('regionCount')]",
        "input": "[concat('r',copyIndex('regionSuffix',1))]"
      },
      {
        "name": "eventHubName",
        "count": "[variables('regionCount')]",
        "input": "[concat(variables('appName'),'ehub-',variables('regionSuffix')[copyIndex('eventHubName')],'-',parameters('environment'))]"
      }
    ]
  },
  "resources": [
   
    {
      "type": "Microsoft.EventHub/namespaces",
      "apiVersion": "[variables('eventHubNMApiVersion')]",
      "name": "[variables('eventHubName')[copyIndex()]]",
      "copy": {
        "name": "resourceLoop",
        "count": "[variables('regionCount')]"
      },
      "location": "[variables('location')[copyIndex()]]",
      "sku": {
        "name": "Standard",
        "tier": "Standard",
        "capacity": 1
      },
      "properties": {
        "zoneRedundant": false,
        "isAutoInflateEnabled": true,
        "maximumThroughputUnits": 1,
        "kafkaEnabled": true
      },
      "resources": [
        {
          "type": "Microsoft.EventHub/namespaces/eventhubs",
          "apiVersion": "[variables('eventHubApiVersion')]",
          "name": "[concat(variables('eventHubName')[copyIndex()], '/',parameters('progressRecordsEventHubName'))]",
          "location": "[variables('location')[copyIndex()]]",
          "dependsOn": [
            "[resourceId('Microsoft.EventHub/namespaces', variables('eventHubName')[copyIndex()])]"
          ],
          "properties": {
            "messageRetentionInDays": 3,
            "partitionCount": 1,
            "status": "Active"
          },
          "resources": [
            {
              "type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
              "apiVersion": "[variables('eventHubApiVersion')]",
              "name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
              "location": "[variables('location')[copyIndex()]]",
              "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
              ],
              "properties": {
                "rights": [
                  "Listen"
                ]
              }
            }
          ]
        }
      ]
    }      
  ],
  "functions": [    
  ],
  "outputs": {}
}

在這方面與 Azure 支持人員合作。 Azure 方面存在問題。 今天(11/19/2020)自動解決了。 模板不再因多個身份驗證規則而失敗。

這篇文章可能有用: https : //www.rickvandenbosch.net/blog/error-creating-service-bus-authorization-rules-using-arm/

我認為模板不會兩次期待相同的資源,因為這些Listen, Send授權規則可以組合如下:

          "resources": [
            {
              "type": "Microsoft.EventHub/namespaces/eventhubs/authorizationRules",
              "apiVersion": "[variables('eventHubApiVersion')]",
              "name": "[concat(variables('eventHubName')[copyIndex('resourceLoop')], '/',parameters('progressRecordsEventHubName'),'/Listen')]",
              "location": "[variables('location')[copyIndex()]]",
              "dependsOn": [
                "[resourceId('Microsoft.EventHub/namespaces/eventhubs', variables('eventHubName')[copyIndex()],parameters('progressRecordsEventHubName'))]"
              ],
              "properties": {
                "rights": [
                  "Listen",
                  "Send"
                ]
              }
            },

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM