ARM Template for Virtual WAN Network Connection

Copper Contributor

Has anyone successfully created ARM Template to automate VNET Connection among VWANHub and spoke VNET. I have Subs A where my VWAN and Sub B where my spoke VNET is located. I have template that works if I enter spoke VNET resource ID as parameter. What I'm trying to do is if I have request for new spoke VNET than to prompt for VNET (name, address prefix, etc) and then create VNET and get VNET output and use it to create VNET Connection. I'm using Nested template and this works fine if my VWAN/Hub and spoke VNET are in same subscription.

2 Replies
Forgot to update this post, my ARM template works now.
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualWanName": {
"type": "string",
"metadata": {
"description": "The name of the Virtual WAN."
}
},
"virtualWanLocation": {
"type": "string",
"metadata": {
"description": "The location of the Virtual WAN."
}
},
"vnetName1": {
"type": "string",
"metadata": {
"description": "The name of the first VNET to connect to the VWAN."
}
},
"vnetName2": {
"type": "string",
"metadata": {
"description": "The name of the second VNET to connect to the VWAN."
}
},
"vnet1ResourceId": {
"type": "string",
"metadata": {
"description": "The resource ID of the first VNET to connect to the VWAN."
}
},
"vnet2ResourceId": {
"type": "string",
"metadata": {
"description": "The resource ID of the second VNET to connect to the VWAN."
}
}
},
"resources": [
{
"type": "Microsoft.Network/virtualWans",
"apiVersion": "2021-02-01",
"name": "[parameters('virtualWanName')]",
"location": "[parameters('virtualWanLocation')]",
"properties": {
"type": "Basic",
"vpnSites": [],
"securityProviderName": "TrustedSecurityPartner",
"disableVpnEncryption": false
},
"resources": [
{
"type": "virtualHubs",
"apiVersion": "2021-02-01",
"name": "hub1",
"location": "[parameters('virtualWanLocation')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualWans/', parameters('virtualWanName'))]"
],
"properties": {
"addressPrefix": "10.0.0.0/24",
"virtualNetworkConnections": [
{
"name": "connection1",
"properties": {
"remoteVirtualNetwork": {
"id": "[parameters('vnet1ResourceId')]"
},
"connectionType": "Vnet2Vnet",
"routingWeight": 10,
"sharedKey": "mysharedkey"
}
},
{
"name": "connection2",
"properties": {
"remoteVirtualNetwork": {
"id": "[parameters('vnet2ResourceId')]"
},
"connectionType": "Vnet2Vnet",
"routingWeight": 10,
"sharedKey": "mysharedkey"
}
}
]
}
}
]
}
]
}