I have a resource group called network-rg containing a virtual network. I am trying to deploy a Virual Machine in a new resource group vm-rg. The VM should be connected to a new subnet on the vnet in network-rg. I am using one single ARM template with both the subnet and the VM and deploying to vm-rg. How do I specify the subnet in the ARM template when its vnet is in another resource group than the primary/default group for the deployment?
I would need to explicitly reference the vnet with the resource group. This would be similar to how a Network Interface deploy is referencing the subnet ID in its ipConfigurations properties list:
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}]
}
subscription().subscriptionId
docs.microsoft.com/en-us/azure/azure-resource-manager/… – The Fish"[resourceId(parameters('vnetResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
What I don't understand is how to supply the ID of the vnet resource into the subnet template when creating the subnet. – Mattias