问题描述
似乎ARM参数文件不支持数组类型值。参数文件中的数组类型值以前可以使用,但是突然从所有现有模板中破坏了。
必须将数组类型参数的值放入模板中以使其起作用。
模板文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json","contentVersion": "1.0.0.0","parameters": {
"names": {
"type": "array","Metadata": {
"description": "Indicate the name of app insight."
},"defaultvalue": [
"ain01","ain02"
]
}
},"variables": {
},"resources": [
{
"apiVersion": "2014-04-01","name": "[parameters('names')[copyIndex()]]","type": "Microsoft.Insights/components","location": "canadacentral","copy": {
"count": "[length(parameters('names'))]","name": "aincopy"
},"properties": {
"applicationId": "[parameters('names')[copyIndex()]]"
}
}
],"outputs": {
"names": {
"type": "array","value": "[parameters('names')]"
}
}
}
参数文件:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#","parameters": {
"names": {
"value": [
"ain03","ain04"
]
}
}
}
解决方法
似乎最新的az.resources 2.5.0模块有问题,无法从参数文件正确读取数组值。我已回滚到旧模块,一切正常。
,我遇到了同样的问题,可以确认回滚到az.resources 2.4.0解决了该问题。
Uninstall-Module -Name Az.Resources
Install-Module -Name Az.Resources -RequiredVersion 2.4.0