使用副本

时间:2016-05-25 15:40:20

标签: azure azure-web-sites cname azure-traffic-manager arm-template

我在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部分?在这种情况下,依赖顺序是否重要?应该吗?

2 个答案:

答案 0 :(得分:1)

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

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

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

答案 1 :(得分:1)

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

可以通过使用for ( int a=0; a<vl.size();a++) { List<String> tmp = vl.get(a); String firstE = ls.get(a); for (int j = 0; j < tmp.size(); j++) { if (j == 0) { //xu.versionUpdate(previousVersion, tmp.get(j)); //String previousVersiontt = ls.get(i); System.out.println(firstE + "----" + tmp.get(j)); } /*xu.versionUpdate(previousVersion, tmp.get(j)); previousVersion=tmp.get(j);*/ //System.out.println(previousVersion+"-"+tmp.get(j)); // previousVersion = tmp.get(j); } } } "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"属性的说明可在此处找到:

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