使用模板更新现有 VNET 的 DNS
updating DNS of Existing VNET using template
提前致谢,我是 ARM 模板的新手,仍在学习它的工作原理。
我有一个包含资源的 VNET,VNET 地址 space 是 10.0.0.0/16,它包含一个子网,地址 space 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":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code": "BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"InvalidRequestFormat\",\r\n \"message\": \"Cannot parse the request.\",\r\n \"details\": [\r\n {\r\n \"code\": \"InvalidJson\",\r\n \"message\": \"Error converting value \"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}"}]}"
您的模板需要数组作为 virtualNetworkSubnetaddress
的值,而您正在传递一个字符串。值应该是这样的:
"value": [
"10.0.0.0/16"
]
Json语法阅读:https://www.digitalocean.com/community/tutorials/an-introduction-to-json
提前致谢,我是 ARM 模板的新手,仍在学习它的工作原理。 我有一个包含资源的 VNET,VNET 地址 space 是 10.0.0.0/16,它包含一个子网,地址 space 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":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code": "BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"InvalidRequestFormat\",\r\n \"message\": \"Cannot parse the request.\",\r\n \"details\": [\r\n {\r\n \"code\": \"InvalidJson\",\r\n \"message\": \"Error converting value \"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}"}]}"
您的模板需要数组作为 virtualNetworkSubnetaddress
的值,而您正在传递一个字符串。值应该是这样的:
"value": [
"10.0.0.0/16"
]
Json语法阅读:https://www.digitalocean.com/community/tutorials/an-introduction-to-json