output/20260723_081532/govviz/ALZ_20260723_081601/Enterprise-Scale/eslzArm/subscriptionTemplates/vwan-sidecar.json

{
    "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "vnetName": {
            "type": "string",
            "defaultValue": "vnet01-sidecar",
            "metadata": {
                "description": "Name of new or existing vnet"
            }
        },
        "vnetIpPrefix": {
            "type": "string",
            "defaultValue": "10.101.0.0/16",
            "metadata": {
                "description": "IP prefix for available addresses in vnet address space"
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Azure region for Bastion and virtual network"
            }
        },
        "topLevelManagementGroupPrefix": {
            "type": "string",
            "metadata": {
                "description": "Name of the intermediate root management group"
            }
        },
        "resourceGroupOverride": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "Name of the resource group to deploy to"
            }
        },
        "vwanHubResourceId": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "Provide full resourceId of VWAN Hub"
            }
        }
    },
    "variables": {
        "resourceDeploymentName": "[format('{0}-deployment', parameters('vnetName'))]",
        "rgName": "[if(empty(parameters('resourceGroupOverride')), concat('rg-', parameters('topLevelManagementGroupPrefix'), '-vnethub-', parameters('location')), parameters('resourceGroupOverride'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Resources/resourceGroups",
            "apiVersion": "2019-10-01",
            "location": "[parameters('location')]",
            "name": "[variables('rgName')]",
            "properties": {}
        },
        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2019-10-01",
            "name": "[variables('resourceDeploymentName')]",
            "resourceGroup": "[variables('rgName')]",
            "dependsOn": [
                "[concat('Microsoft.Resources/resourceGroups/', variables('rgName'))]"
            ],
            "properties": {
                "mode": "Incremental",
                "expressionEvaluationOptions": {
                    "scope": "inner"
                },
                "parameters": {
                    "location": {
                        "value": "[parameters('location')]"
                    },
                    "vnetName": {
                        "value": "[parameters('vnetName')]"
                    },
                    "vnetIpPrefix": {
                        "value": "[parameters('vnetIpPrefix')]"
                    },
                    "vwanHubResourceId": {
                        "value": "[parameters('vwanHubResourceId')]"
                    },
                    "rgName": {
                        "value": "[variables('rgName')]"
                    }
                },
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "location": {
                            "type": "string"
                        },
                        "vnetName": {
                            "type": "string"
                        },
                        "vnetIpPrefix": {
                            "type": "string"
                        },
                        "vwanHubResourceId": {
                            "type": "string"
                        },
                        "rgName": {
                            "type": "string"
                        }
                    },
                    "variables": {
                        "nsgName": "[format('{0}-nsg', parameters('vnetName'))]"
                    },
                    "resources": [
                        {
                            "type": "Microsoft.Network/networkSecurityGroups",
                            "apiVersion": "2022-07-01",
                            "name": "[variables('nsgName')]",
                            "location": "[parameters('location')]",
                            "properties": {
                                "securityRules": [
                                ]
                            }
                        },
                        {
                            "type": "Microsoft.Network/virtualNetworks",
                            "apiVersion": "2022-07-01",
                            "name": "[parameters('vnetName')]",
                            "location": "[parameters('location')]",
                            "properties": {
                                "addressSpace": {
                                    "addressPrefixes": [
                                        "[parameters('vnetIpPrefix')]"
                                    ]
                                },
                                "subnets": []
                            },
                            "dependsOn": [
                                "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
                            ]
                        },
                        {
                            "type": "Microsoft.Resources/deployments",
                            "apiVersion": "2020-06-01",
                            "name": "[concat('alz-vwanhub-sidecar-peering-', parameters('location'), '-', substring(uniqueString(subscription().id),0,6))]",
                            "subscriptionId": "[split(parameters('vWanhubResourceId'),'/')[2]]",
                            "resourceGroup": "[split(parameters('vWanhubResourceId'),'/')[4]]",
                            "dependsOn": [
                                "[parameters('vNetName')]"
                            ],
                            "properties": {
                                "mode": "Incremental",
                                "expressionEvaluationOptions": {
                                    "scope": "inner"
                                },
                                "parameters": {
                                    "remoteVirtualNetwork": {
                                        "value": "[concat(subscription().id,'/resourceGroups/',parameters('rgName'), '/providers/','Microsoft.Network/virtualNetworks/', parameters('vNetName'))]"
                                    },
                                    "vWanvhubName": {
                                        "value": "[split(parameters('vWanhubResourceId'),'/')[8]]"
                                    }
                                },
                                "template": {
                                    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                                    "contentVersion": "1.0.0.0",
                                    "parameters": {
                                        "remoteVirtualNetwork": {
                                            "Type": "string",
                                            "defaultValue": false
                                        },
                                        "vWanvhubName": {
                                            "Type": "string",
                                            "defaultValue": false
                                        }
                                    },
                                    "variables": {},
                                    "resources": [
                                        {
                                            "type": "Microsoft.Network/virtualHubs/hubVirtualNetworkConnections",
                                            "apiVersion": "2020-05-01",
                                            "name": "[concat(parameters('vWanVhubName'),'/',last(split(parameters('remoteVirtualNetwork'),'/')))]",
                                            "properties": {
                                                "remoteVirtualNetwork": {
                                                    "id": "[parameters('remoteVirtualNetwork')]"
                                                }
                                            }
                                        }
                                    ],
                                    "outputs": {}
                                }
                            }
                        }
                    ]
                }
            }
        }
    ]
}