2
votes

I am trying to deploy a VM using ARM template and static IP. My vnet is in network resource group and I am creating my NIC in compute resource group with VM. My ARM template is failing because it is trying to search the vnet/subnet under compute resource group while creating VM NIC... How to handle this situation ?

1

1 Answers

5
votes

you need to provide the proper resourceId to the NIC while attaching it to the vnet\subnet, like this:

"subnet": {
    "id": "[resourceId('resourceGroupName', 'Microsoft.Network/virtualNetworks/Subnets', 'vnetName', 'subnetName')]",
},

where resourceGroupName is the name of the resourceGroup your vnet resides in. you can pick a vnet in a different subscription with this function as well. or you can just "calculate" it with concat function, or outside of the template.

more reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#resourceid