gpt4 book ai didi

azure - 使用副本的 Microsoft.Web/sites/hostNameBindings 资源的 ARM 模板部署

转载 作者:行者123 更新时间:2023-12-03 20:18:35 25 4
gpt4 key购买 nike

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

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

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

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

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

最佳答案

正如其他人提到的,流量管理器似乎会导致异步 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://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#resource-iteration

关于azure - 使用副本的 Microsoft.Web/sites/hostNameBindings 资源的 ARM 模板部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37441886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com