在此先感谢,我是ARM模板的新手,仍在学习它是如何工作的。我有一个带有资源的VNET,VNET地址空间是10.0.0.0/16,它包含一个地址空间为10.0.0.0/16的子网我正在尝试使用ARM模板更新DNS,它会抛出一个错误
"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": {}
}
下面是我的参数文件
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"dnsaddress": {
"value": ["10.0.0.4"]
},
"location": {
"value": "East US"
},
"virtualNetworkAddressRange": {
"value": "10.0.0.0/16"
},
"virtualNetworkName": {
"value": "vnettest"
},
"virtualNetworkSubnetaddress": {
"value": ["10.0.0.0/16"]
}
}
}
我不确定我做错了什么。
我尝试使用[]括号和获取错误
“{”code“:”DeploymentFailed“,”message“:”至少有一个资源部署操作失败。请列出部署操作以获取详细信息有关使用详情,请参阅https://aka.ms/arm-debug。“,”详细信息“:[{”code“:”BadRequest“,”message“:”{\ r \ n \“错误\”:{\ r \ n \“代码\”: \“InvalidRequestFormat \”,\ r \ n \“message \”:\“无法解析请求。\”,\ r \ n \“details \”:[\ r \ n {\ r \ n \“代码\ “:\”InvalidJson \“,\ r \ n \”message \“:\”将值\\“10.0.0.0/16 \\”转换为'Microsoft.WindowsAzure.Networking.Nrp.Frontend.Contract.Csm'时出错.Public.Subnet'.Path'properties.subnets [0]',第1行,第153位。\“\ r \ n} \ r \ n] \ r \ n} \ r \ n}”}}}“
你的模板需要数组作为virtualNetworkSubnetaddress
的值,并且你传入一个字符串。价值应该是这样的:
"value": [
"10.0.0.0/16"
]
Json语法阅读:https://www.digitalocean.com/community/tutorials/an-introduction-to-json