![](/img/trans.png)
[英]Azure ARM Template - accessing a resource Id created by one ARM template in another ARM template
[英]Multiple values for a property on resource in Azure ARM Template
根据https://docs.microsoft.com/zh-CN/azure/azure-resource-manager/resource-group-create-multiple#property-iteration ,应该可以使用副本在资源上创建多个值,但我无法使其工作。 这是我的代码...
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appServiceName": {
"type": "string",
"metadata": {
"description": "Name of app service to apply SSL to."
}
},
"certificateName": {
"type": "string",
"metadata": {
"description": "User friendly certificate resource name"
}
},
"appServicePlan": {
"type": "string",
"metadata": {
"description": "App Service Plan Name"
}
},
"keyVaultId": {
"type": "string",
"metadata": {
"description": "Existing Key Vault resource Id with an access policy to allow Microsoft.Web RP to read Key Vault secrets (Checkout README.md for more information)"
}
},
"hostname": {
"type": "array",
"metadata": {
"description": "Custom hostname for creating SSL binding. This hostname should already be assigned to the Web App"
}
}
},
"resources": [
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Web/sites",
"name": "[parameters('appServiceName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/certificates', parameters('certificateName'))]"
],
"properties": {
"copy": [
{
"name": "hostnames",
"count": "[length(parameters('hostname'))]",
"input": {
"name": "[copyIndex('hostnames')]",
"properties": {
"hostNameSslStates": [
{
"name": "[[copyIndex(hostname)]]",
"sslState": "SniEnabled",
"thumbprint": "[reference(resourceId('Microsoft.Web/certificates', parameters('certificateName'))).Thumbprint]",
"toUpdate": true
}
]
}
}
}
]
}
},
{
"type": "Microsoft.Web/certificates",
"name": "[parameters('certificateName')]",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": {
"keyVaultId": "[parameters('keyVaultId')]",
"keyVaultSecretName": "[parameters('certificateName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms',parameters('appServicePlan'))]"
}
}
]
}
并返回错误:Code = InvalidTemplate; 消息=部署模板语言表达式评估失败:“无法解析语言表达式'copyIndex(hostname)]':期望标记'LeftParenthesis'和实际的'RightParenthesis'。”。 有关用法的详细信息,请参见https://aka.ms/arm-template-expressi 。
有什么想法我做错了吗?
提前致谢!
错误给出了:
将"[[copyIndex(hostname)]]",
更改为"[copyIndex('hostname')]"
您甚至在其他地方都拥有它,为什么不在这里?
并且您可能想这样做:
"[parameters('hostname')[copyIndex('hostname')]]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.