An Azure ARM Template that deploys a VNET, and peers the newly deployed VNET with an existing VNET in a different resource group?
Please find the JSON template below:
{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/virtualNetworks",
"name": "SpokevNet",
"location": "[resourceGroup().location]",
"comments": "This is the first vNet",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.238.70.0/25"
]
},
"subnets": [
{
"name": "SpokeSubNet",
"properties": {
"addressPrefix": "10.238.70.0/26"
}
}
]
}
},
{
"apiVersion": "2017-05-10",
"name": "nestedTemplate",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "PrdHUBRG",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2016-06-01",
"type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings",
"name": "virtualNetworks/spoketoHubPeering",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', PrdEUW1VN002)]",
"[concat('Microsoft.Network/virtualNetworks/', SpokevNet)]"
],
"comments": "This is the peering from vNet 1 to vNet 2",
"properties": {
"allowVirtualNetworkAccess": "true",
"allowForwardedTraffic": "false",
"allowGatewayTransit": "false",
"useRemoteGateways": "false",
"remoteVirtualNetwork": {
"id": "/subscriptions/4adb8053-2339-4041-802d-d0b0f8fe3487/resourceGroups/PrdHUBRG/providers/Microsoft.Network/virtualNetworks/PrdEUW1VN002"
}
}
}
]
},
"parameters": {}
}
}
}
]
}
And this is the error that I keep getting:
{"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":"Conflict","message":"{\r\n \"status\": \"Failed\",\r\n \"error\": {\r\n \"code\": \"ResourceDeploymentFailure\",\r\n \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n \"details\": [\r\n {\r\n \"code\": \"DeploymentFailed\",\r\n \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.\",\r\n \"details\": [\r\n {\r\n \"code\": \"NotFound\",\r\n \"message\": \"{\\r\\n \\\"error\\\": {\\r\\n \\\"code\\\": \\\"ResourceNotFound\\\",\\r\\n \\\"message\\\": \\\"The Resource 'Microsoft.Network/virtualNetworks/virtualNetworks' under resource group 'PrdHUBRG' was not found.\\\"\\r\\n }\\r\\n}\"\r\n }\r\n ]\r\n }\r\n ]\r\n }\r\n}"}]}