使用copy复制Microsoft.Web / sites / hostNameBindings资源的ARM模板部署

问题描述 投票:3回答:2

我在Azure数据中心位置阵列上使用复制操作,以便按位置部署应用服务计划和网站。我能够创建流量管理器配置文件并使用复制对象将每个位置的端点添加到流量管理器配置文件。

当我尝试将每个网站的CNAME设置为我的自定义域名时,根据here的说明使用Microsoft.Web / sites / hostNameBindings资源,我想出了以下内容:

   {
      "type": "Microsoft.Web/sites/hostNameBindings",
      "apiVersion": "[parameters('hostNameBindingsApiVersion')]",
      "copy": {
        "name": "hostNameBindingsEndpointsLoop",
        "count": "[length(parameters('appServicePlanLocations'))]"
      },
      "name": "[concat(concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()]), '/', variables('hostNameBindingsName'))]",
      "location": "[parameters('appServicePlanLocations')[copyIndex()]]",
      "dependsOn": [
        "[concat('Microsoft.Network/trafficManagerProfiles/', variables('trafficManagerName'), '/azureEndpoints/', variables('trafficManagerEndpointPrefix'), parameters('appServicePlanLocations')[copyIndex()])]",
        "[concat('Microsoft.Web/sites/', concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()]))]"
      ],
      "properties": {
        "siteName": "[concat(variables('webSitePrefix'), parameters('appServicePlanLocations')[copyIndex()])]",
        "domainId": null,
        "hostNameType": "Verified"
      }
    }

使用此方法,实际设置了CNAME,但ARM模板部署失败,并显示以下错误:

{
      "ErrorEntity": {
        "Code": "Conflict",
        "Message": "Cannot modify this site because another operation is in progress. Details: Id: {guid}, OperationName: RegisterTrafficManagerProfile, CreatedTime: 5/24/2016 11:13:54 PM, RequestId: {guid}, EntityType: 1",
        "ExtendedCode": "59203",
        "MessageTemplate": "Cannot modify this site because another operation is in progress. Details: {0}",
        "Parameters": [
          "Id: {guid}, OperationName: RegisterTrafficManagerProfile, CreatedTime: 5/24/2016 11:13:54 PM, RequestId:{guid}, EntityType: 1"
        ],
        "InnerErrors": null
      }
    }
  ],
  "Innererror": null
}

我不确定冲突是什么,因为我添加了依赖段以尝试等待创建网站以及trafficmanagerendpoint来完成其配置。我将尝试更改顺序,以便在创建网站后,我将添加CNAME,然后让流量管理器端点等待CNAME创建。我不明白为什么订单应该有所作为。

我是否正确定义了arm模板的Microsoft.Web / sites / hostNameBindings部分?在这种情况下,依赖顺序是否重要?应该是?

azure azure-web-sites cname azure-traffic-manager arm-template
2个回答
1
投票

正如其他人所提到的那样,Traffic Manager似乎会导致异步hostNameBindings迭代操作出现问题。

可以使用"mode": "serial"使用"batchsize": 1模式指定同步副本来解决此问题:

{
   "type": "Microsoft.Web/sites/hostNameBindings",
   "apiVersion": "[parameters('hostNameBindingsApiVersion')]",
   "copy": {
     "name": "hostNameBindingsEndpointsLoop",
     "count": "[length(parameters('appServicePlanLocations'))]",

     /* FIX for Asynchronous Hostname Conflict */
     "mode": "serial",
     "batchSize": 1
  },
  …

可在此处找到"mode""batchSize"属性的说明:

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#resource-iteration


1
投票

向交通管理器添加Web应用程序时,在两个服务之间的幕后发生一些异步协调,以检查Web应用程序SKU是否符合流量管理器的条件,并在Web应用程序自定义中注册流量管理器DNS名称域名列表。

看来这个异步过程导致了您看到的错误。您建议撤销订单,以便在流量管理器注册之前创建您的CNAME应该有效(我有兴趣听听它是否有效)。

Azure网络项目经理Jonathan Tuliani - DNS和流量管理器

© www.soinside.com 2019 - 2024. All rights reserved.