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

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

问题描述

我对一系列 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 设置为我的自定义域名时,按照说明使用 Microsoft.Web/sites/hostNameBindings 资源 这里想出了以下内容:

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
}

我不确定冲突是什么,因为我添加了依赖段以尝试等待创建网站以及流量管理端点完成其配置.我将尝试更改顺序,以便在创建网站后添加 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/en-us/azure/azure-resource-manager/resource-group-create-multiple#resource-iteration

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

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