预先感谢,我是ARM模板的新手,并且仍在学习它的工作原理。 我有一个带有资源的VNET,VNET地址空间为10.0.0.0/16,它包含一个地址空间为10.0.0.0/16的单个子网 我正在尝试使用ARM模板更新DNS,并且抛出错误
[ {
"a" : [ "1", "2", "3" ]
}, {
"a" : [ "1", "2", "3" ]
} ]
这是我的部署文件
"New-AzureRmResourceGroupDeployment : 11.50.14 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The provided value for the template parameter 'virtualNetworkSubnetaddress' at line
'26' and column '40' is not valid.'."
下面是我的参数文件
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"metadata": {
"Description": "The region to deploy the resources into"
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"Description": "The name of the Virtual Network"
}
},
"virtualNetworkAddressRange": {
"type": "string",
"metadata": {
"Description": "The address range of the virtual network in CIDR format"
},
"defaultValue": "10.0.0.0/16"
},
"virtualNetworkSubnetaddress": {
"type": "array",
"metadata": {
"Description": "The subnet definition for the virtual network"
}
},
"dnsAddress": {
"type": "array",
"metadata": {
"Description": "The DNS address(es) of the DNS Server(s) used by the virtual network"
}
},
},
"resources": [
{
"name": "[parameters('virtualNetworkName')]",
"type": "Microsoft.Network/virtualNetworks",
"location": "[parameters('location')]",
"apiVersion": "2018-02-01",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[parameters('virtualNetworkAddressRange')]"
]
},
"dhcpOptions": {
"dnsServers": "[parameters('dnsAddress')]"
},
"subnets": "[parameters('virtualNetworkSubnetaddress')]"
}
}
],
"outputs": {}
}
我不确定自己在做什么错。
我尝试使用[]括号并出现错误
“ {”代码“:” DeploymentFailed“,”消息“:”“至少一项资源部署操作失败。请列出部署操作以获取详细信息。有关用法的详细信息,请参见https://aka.ms/arm-debug。“,”详细信息“:[{”代码“:” BadRequest“,”消息“:” {\ r \ n \“ error \”:{\ r \ n \“ code \“:\” InvalidRequestFormat \“,\ r \ n \” message \“:\”无法解析请求。\“,\ r \ n \” details \“:[\ r \ n {\ r \ n \“ code \”:\“ InvalidJson \”,\ r \ n \“ message \”:\“将值\\” 10.0.0.0/16 \\“转换为键入'Microsoft.WindowsAzure.Networking.Nrp.Frontend时出错.Contract.Csm.Public.Subnet'。路径'properties.subnets [0]',第1行,位置153。\“ \ r \ n} \ r \ n] \ r \ n} \ r \ n}”} ]}“
答案 0 :(得分:1)
您的模板期望将数组作为virtualNetworkSubnetaddress
的值,并且您正在传递字符串。值应该是这样:
"value": [
"10.0.0.0/16"
]
Json语法阅读:https://www.digitalocean.com/community/tutorials/an-introduction-to-json