title: Azure ARM Template with VM and subnet
body: <p>I have a resource group called <em>network-rg</em> containing a virtual network. I am trying to deploy a Virual Machine in a new resource group <em>vm-rg</em>. The VM should be connected to a new subnet on the vnet in <em>network-rg</em>. I am using one single ARM template with both the subnet and the VM and deploying to vm-rg. <strong>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?</strong> </p>
  
  <p>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:</p>
  
  <pre><code>  "apiVersion": "2015-05-01-preview",
    "type": "Microsoft.Network/networkInterfaces",
    "name": "[parameters('nicName')]",
    "location": "[parameters('location')]",
    "properties": {
        "ipConfigurations": [{
            "name": "ipconfig1",
            "properties": {
                "subnet": {
                    "id": "[variables('subnet1Ref')]"
                }
            }
        }]
     }
  </code></pre>