使用副本的Microsoft.Web/sites/hostNameBindings资源的ARM模板部署 [英] ARM template deployment of Microsoft.Web/sites/hostNameBindings resources using copy

查看:56
本文介绍了使用副本的Microsoft.Web/sites/hostNameBindings资源的ARM模板部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I use a copy operation over an array of Azure data center locations in order to deploy an app service plan and a website per location. I am able to create a traffic manager profile and use the copy object to add an endpoint per location to the traffic manager profile.

当我尝试将每个网站的CNAME设置为我的自定义域名时,请按照

When I try to set the CNAME for each of the web sites to my custom domain name, using the Microsoft.Web/sites/hostNameBindings resource per the instructions here I came up with the following:

   {
      "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模板部署失败,并出现以下错误:

Using this, the CNAME is actually set but the ARM template deployment fails with the following error:

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

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

I'm not sure what the conflict is because I've added the dependson segment to attempt to wait for both the website to be created as well as the trafficmanagerendpoint to complete its provisioning. I'm going to try to change the order such that after the website is created, I'll add the CNAME and then have the traffic manager endpoint await the CNAME creation. I don't see why the order should make a difference.

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

Have I defined the Microsoft.Web/sites/hostNameBindings section of my arm template correctly? Does the dependson order matter in this scenario? Should it?

推荐答案

正如其他人所提到的,似乎流量管理器会导致异步hostNameBindings迭代操作出现问题.

As mentioned by others it seems Traffic Manager causes a problem with the asynchronous hostNameBindings iteration operation.

可以通过使用"mode": "serial"模式和"batchsize": 1指定同步副本来解决:

It can be resolved by specifying a synchronous copy using "mode": "serial" mode with "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"属性的说明可在此处找到:

Explanation of the "mode" and "batchSize" properties can be found here:

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

这篇关于使用副本的Microsoft.Web/sites/hostNameBindings资源的ARM模板部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆