gpt4 book ai didi

json - Arm 模板中的 copyindex() 错误

转载 作者:行者123 更新时间:2023-12-02 07:35:26 25 4
gpt4 key购买 nike

这是我的参数文件:

"VNetSettings": {
"value": {
"name": "VNet1",
"addressPrefixes": "10.0.0.0/16",
"subnets": [
{
"name": "sub1",
"addressPrefix": "10.0.1.0/24"
},
{
"name": "sub2",
"addressPrefix": "10.0.2.0/24"
}
]
}
}

这是我的部署文件(deploy.json)

{
"contentversion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"parameters": {
"VNetSettings": {
"type": "object"
},
"noofsubnets": {
"type": "int"
}
},
"resources": [
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('VNetSettings').name]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('VNetSettings').addressPrefixes]"
]
},
"copy": {
"name": "subnets",
"count": "[parameters('noofsubnets')]",
"input": {
"name": "[parameters('VNetSettings').subnets[copyIndex('subnets',1)].name]",
"properties": {
"addressPrefix": "[parameters('VNetSettings').subnets[copyIndex('subnets',1)].addressPrefix]"
}
}
}
}
}
]
}

部署arm模板应该做的是启动具有各自地址前缀的子网(例如:sub1 -> 10.0.1.0/24,sub2 -> 10.0.2.0/24),但是当我从powershell执行模板时使用以下命令:

New-AzureRmResourceGroupDeployment -Name testing -ResourceGroupName rgname -TemplateFile C:\Test\deploy.json -TemplateParameterFile C:\Test\parameterfile.json 

我显示以下错误:

The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Error says there is something wrong with the copyindex() but I'm unable to find out what exactly is wrong with it.

最佳答案

副本必须如下所示:

"copy": [
{
"name": "xxx",
"count": "xxx",
"input": { ... }
}
]

您缺少[]

关于json - Arm 模板中的 copyindex() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49270901/

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