4

我已經創建了用於部署Azure服務總線的ARM模板,該模板還包含事件中心和隊列。該模板成功創建隊列和事件中心,但某些時候,授權規則不會創建(20%的時間)。下面是我在奮鬥後創建的模板的修剪版本:P。爲什麼我的ARM模板無法一致地創建授權規則?

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
     "location": { 
      "type": "string", 
      "defaultValue": "South Central US", 
      "metadata": { 
       "description": "The location where all azure resources will be deployed." 
      } 
     }, 
     "serviceBusNamespace": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the service bus namespace to create." 
      } 
     }, 
     "queueName": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the queue to create." 
      } 
     }, 
     "hubName": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the event hub to create." 
      } 
     }, 
     "messagingSku": { 
      "type": "int", 
      "minValue": 1, 
      "defaultValue": 1, 
      "metadata": { 
       "description": "The SKU version." 
      } 
     }, 
     "queueMaxSizeInGB": { 
      "type": "int", 
      "minValue": 1, 
      "defaultValue": 1, 
      "maxValue": 16, 
      "metadata": { 
       "description": "The queue max size." 
      } 
     }, 
     "partitionCount": { 
      "type": "int", 
      "minValue": 2, 
      "defaultValue": 2, 
      "maxValue": 32, 
      "metadata": { 
       "description": "The partition count of event hub." 
      } 
     } 
    }, 
    "variables": { 
     "queueSize": "[mul(parameters('queueMaxSizeInGB'),1024)]", 
     "managePolicy": "ManagePolicy", 
     "sendPolicy": "SendPolicy", 
     "listenPolicy": "ListenPolicy" 
    }, 
    "resources": [ 
     { 
      "apiVersion": "2014-09-01", 
      "name": "[parameters('serviceBusNamespace')]", 
      "type": "Microsoft.ServiceBus/namespaces", 
      "location": "[parameters('location')]", 
      "properties": { 
       "messagingSku": "[parameters('messagingSku')]" 
      }, 
      "resources": [ 
       { 
        "apiVersion": "2014-09-01", 
        "name": "[parameters('queueName')]", 
        "type": "Queues", 
        "dependsOn": [ 
         "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]" 
        ], 
        "properties": { 
         "path": "[parameters('queueName')]", 
         "maxSizeInMegabytes": "[variables('queueSize')]" 
        }, 
        "resources": [ 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('managePolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]" 
          ], 
          "properties": { 
           "Rights": [ 
            "Send", 
            "Listen", 
            "Manage" 
           ] 
          } 
         }, 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('sendPolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]" 
          ], 
          "properties": { 
           "Rights": [ 
            "Send" 
           ] 
          } 
         }, 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('listenPolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]" 
          ], 
          "properties": { 
           "Rights": [ 
            "Listen" 
           ] 
          } 
         } 
        ] 
       }, 
       { 
        "apiVersion": "2014-09-01", 
        "name": "[parameters('hubName')]", 
        "type": "EventHubs", 
        "dependsOn": [ 
         "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]" 
        ], 
        "properties": { 
         "path": "[parameters('hubName')]", 
         "partitionCount": "[parameters('partitionCount')]" 
        } 
       } 
      ] 
     } 
    ], 
    "outputs": { 
     "queueManagePolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('managePolicy')),'2015-08-01').primaryConnectionString]" 
     }, 
     "queueSendPolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('sendPolicy')),'2015-08-01').primaryConnectionString]" 
     }, 
     "queueListenPolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('listenPolicy')),'2015-08-01').primaryConnectionString]" 
     } 
    } 
} 

有人也有同樣的問題,或者我失去了一些愚蠢的東西?有沒有修復?

任何幫助,非常感謝。

+0

它是否在創建授權規則時拋出任何錯誤? –

+0

在github中獲得了此模板,似乎可以正常工作。檢查出來https://github.com/sjkp/Azure.ARM.ServiceBus/blob/master/Azure.ARM.ServiceBus/Templates/DeploymentTemplate.json – Aravind

+0

@JackZeng由於我已經定義了輸出,它確實會拋出錯誤。沒有,它工作正常 – Sandesh

回答

8

MS幫我解決了這個問題。問題是授權規則是並行創建的,RM不喜歡。解決這個問題的方法是簡單地創建一個SAS令牌。以下是持續工作的ARM模板

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
     "location": { 
      "type": "string", 
      "defaultValue": "South Central US", 
      "metadata": { 
       "description": "The location where all azure resources will be deployed." 
      } 
     }, 
     "serviceBusNamespace": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the service bus namespace to create." 
      } 
     }, 
     "queueName": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the queue to create." 
      } 
     }, 
     "hubName": { 
      "type": "string", 
      "minLength": 1, 
      "metadata": { 
       "description": "The name of the event hub to create." 
      } 
     }, 
     "messagingSku": { 
      "type": "int", 
      "minValue": 1, 
      "defaultValue": 1, 
      "metadata": { 
       "description": "The SKU version." 
      } 
     }, 
     "queueMaxSizeInGB": { 
      "type": "int", 
      "minValue": 1, 
      "defaultValue": 1, 
      "maxValue": 16, 
      "metadata": { 
       "description": "The queue max size." 
      } 
     }, 
     "partitionCount": { 
      "type": "int", 
      "minValue": 2, 
      "defaultValue": 2, 
      "maxValue": 32, 
      "metadata": { 
       "description": "The partition count of event hub." 
      } 
     } 
    }, 
    "variables": { 
     "queueSize": "[mul(parameters('queueMaxSizeInGB'),1024)]", 
     "managePolicy": "ManagePolicy", 
     "sendPolicy": "SendPolicy", 
     "listenPolicy": "ListenPolicy" 
    }, 
    "resources": [ 
     { 
      "apiVersion": "2014-09-01", 
      "name": "[parameters('serviceBusNamespace')]", 
      "type": "Microsoft.ServiceBus/namespaces", 
      "location": "[parameters('location')]", 
      "properties": { 
       "messagingSku": "[parameters('messagingSku')]" 
      }, 
      "resources": [ 
       { 
        "apiVersion": "2014-09-01", 
        "name": "[parameters('queueName')]", 
        "type": "Queues", 
        "dependsOn": [ 
         "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]" 
        ], 
        "properties": { 
         "path": "[parameters('queueName')]", 
         "maxSizeInMegabytes": "[variables('queueSize')]" 
        }, 
        "resources": [ 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('managePolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]" 
          ], 
          "properties": { 
           "Rights": [ 
            "Send", 
            "Listen", 
            "Manage" 
           ] 
          } 
         }, 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('sendPolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]", 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('managePolicy'))]", 
          ], 
          "properties": { 
           "Rights": [ 
            "Send" 
           ] 
          } 
         }, 
         { 
          "apiVersion": "2015-08-01", 
          "name": "[variables('listenPolicy')]", 
          "type": "authorizationRules", 
          "dependsOn": [ 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]", 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('managePolicy'))]", 
           "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('sendPolicy'))]" 
          ], 
          "properties": { 
           "Rights": [ 
            "Listen" 
           ] 
          } 
         } 
        ] 
       }, 
       { 
        "apiVersion": "2014-09-01", 
        "name": "[parameters('hubName')]", 
        "type": "EventHubs", 
        "dependsOn": [ 
         "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]" 
        ], 
        "properties": { 
         "path": "[parameters('hubName')]", 
         "partitionCount": "[parameters('partitionCount')]" 
        } 
       } 
      ] 
     } 
    ], 
    "outputs": { 
     "queueManagePolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('managePolicy')),'2015-08-01').primaryConnectionString]" 
     }, 
     "queueSendPolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('sendPolicy')),'2015-08-01').primaryConnectionString]" 
     }, 
     "queueListenPolicy": { 
      "type": "string", 
      "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('listenPolicy')),'2015-08-01').primaryConnectionString]" 
     } 
    } 
} 
相關問題