title: Azure ARM Template different Resource Group Dependency Issue
body: <p>I have a template that deploys a new template in a dedicated resource group for VNETs.  I want to deploy a network interface in a subnet of the VNET, but put the network interface in its own separate resource group.  When I run the template I receive the following error.  I am sure it is a dependency issue, but the dependsOn parameter is not working for me... any ideas?</p>
  
  <p><strong>Recieved Error</strong></p>
  
  <pre><code>  "error": {
      "code": "InvalidResourceReference",
      "message": "Resource /subscriptions/{removed-subscription-id}/resourceGroups/vnet-resource-group/providers/Microsoft.Network/virtualNetworks/my-vnet/subnets/subnet-1 referenced by resource /subscriptions/{removed-subscription-id}/resourceGroups/test-rg-1/providers/Microsoft.Network/networkInterfaces/my-first-nic was not found. Please make sure that the referenced resource exists, and that both resources are in the same region.",
      "details": []
    }
  }
  </code></pre>
  
  <p><strong>Template</strong></p>
  
  <pre><code>{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "vnetName": {
        "type": "string",
        "defaultValue": "my-vnet"
      },
      "vnetResourceGroup": {
        "type": "string",
        "defaultValue": "vnet-resource-group"
      },
      "nicResourceGroup": {
        "type": "string",
        "defaultValue": "nic-resource-group"
      }
    },
    "variables": {
      "vnetID": "[resourceId(parameters('vnetResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('vnetName'))]",
      "subnetID": "[concat(variables('vnetID'),'/subnets/','subnet-1')]"
    },
    "resources": [
      {
        "apiVersion": "2017-05-10",
        "name": "vnetNestedTemplate",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "[parameters('vnetResourceGroup')]",
        "properties": {
          "mode": "Incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "apiVersion": "2018-06-01",
                "name": "my-vnet",
                "type": "Microsoft.Network/virtualNetworks",
                "location": "[resourceGroup().location]",
                "properties": {
                  "addressSpace": {
                    "addressPrefixes": [
                      "10.0.0.0/16"
                    ]
                  },
                  "subnets": [
                    {
                      "name": "subnet-1",
                      "properties": {
                        "addressPrefix": "10.0.0.0/24"
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      },
      {
        "apiVersion": "2017-05-10",
        "name": "nestedNicTemplate",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "[parameters('nicResourceGroup')]",
        "properties": {
          "mode": "Incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "apiVersion": "2015-06-15",
                "type": "Microsoft.Network/networkInterfaces",
                "name": "my-first-nic",
                "location": "[resourceGroup().location]",
                "dependsOn": [
                  "[resourceId(parameters('vnetResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('vnetName'))]"
                ],
                "properties": {
                  "ipConfigurations": [
                    {
                      "name": "ipconfig1",
                      "properties": {
                        "privateIPAllocationMethod": "Static",
                        "subnet": {
                          "id": "[variables('subnetID')]"
                        },
                        "privateIpAddress": "10.0.0.5"
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      }
    ]
  }
  </code></pre>