【发布时间】:2018-03-21 00:11:39
【问题描述】:
我正在尝试使用此 Azure 资源管理器模板代码 sn-p 将自定义域添加到 web 应用程序集。 Web 应用程序正在正确创建,流量管理器配置文件也是如此。但是,添加自定义主机名时 ARM 模板失败。请注意,我使用的是传递给模板的可变参数来创建网站。
{
"name": "[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex())]",
"type": "Microsoft.Web/sites",
"kind": "app,linux,container",
"location": "[parameters('webAppLocations')[copyIndex()]]",
"apiVersion": "2016-08-01",
"copy": {
"count": "[length(parameters('webAppLocations'))]",
"name": "siteCopy"
},
"dependsOn": [
"farmCopy"
],
"resources": [
{
"name": "appsettings",
"type": "config",
"apiVersion": "2016-08-01",
"dependsOn": [
"[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex())]"
],
"tags": {
"displayName": "Application settings"
},
"properties": {
"publishingUsername": "[variables('publishingUsername')]",
"DOCKER_CUSTOM_IMAGE_NAME": "[parameters('dockerImageName')]"
}
}
],
"tags": {
"[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id))), '-', copyIndex())]": "Resource",
"displayName": "[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex())]"
},
"properties": {
"name": "[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex())]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-', copyIndex()))]"
}
},
{
"type": "Microsoft.Web/sites/hostnameBindings",
"name": "[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex(), '/', parameters('customHostname'))]",
"apiVersion": "2016-08-01",
"location": "[resourceGroup().location]",
"properties": {
},
"dependsOn": [
"[concat('Microsoft.Web/sites/',parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex(), '/', parameters('customHostname'))]"
]
}
2018-03-20T23:50:20.7707394Z ##[error]Deployment template validation failed: 'The template resource '[concat(parameters('webAppNamePrefix'), '-', uniqueString(resourceGroup().id), '-site-', copyIndex(), '/', parameters('customHostname'))]' at line '1' and column '2892' is not valid: The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-copy for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.
2018-03-20T23:50:20.7723109Z ##[error]Task failed while creating or updating the template deployment.
请注意,copyIndex() 对于模板中其他地方的网站名称可以正常工作。那么为什么它不适用于“Microsoft.Web/sites/hostnameBindings”部分呢?我被难住了。
这里是参数。注意 webAppLocations 参数,它是一个数组。
"parameters": {
"webAppNamePrefix": {
"type": "string",
"minLength": 1
},
"dockerImageName": {
"type": "string",
"metadata": {
"description": "Name of docker image to use"
}
},
"farmSkuName": {
"type": "string",
"metadata": {
"description": "Describes plan's pricing tier and capacity. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"environmentType": {
"type": "string",
"allowedValues": [
"dev",
"qa",
"prod"
],
"metadata": {
"description": "Environment type name"
}
},
"webAppLocations": {
"type": "array"
},
"trafficManagerPrefix": {
"type": "string"
},
"customHostname": {
"type": "string",
"metadata": {
"description": "The custom hostname that you wish to add."
}
}
},
【问题讨论】:
标签: azure azure-web-app-service arm-template