Skip to content

Instantly share code, notes, and snippets.

@ploegert
Created May 30, 2015 16:52
Show Gist options
  • Select an option

  • Save ploegert/e033dd3414b1b43aeea7 to your computer and use it in GitHub Desktop.

Select an option

Save ploegert/e033dd3414b1b43aeea7 to your computer and use it in GitHub Desktop.
Often you may want to use a resource from outside of the current resource group where a template is getting deployed. The most common case for this behavior is using a storage account or virtual network in an alternate resource group. This is often needed so that the deletion of the resource group which contains the virtual machines will not res…
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualNetworkName": {
"type": "string"
},
"virtualNetworkResourceGroup": {
"type": "string"
},
"subnet1Name": {
"type": "string"
},
"nicName": {
"type": "string"
}
},
"variables": {
"vnetID": "[resourceId(parameters('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/', parameters('subnet1Name'))]"
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('nicName')]",
"location": "[parameters('location')]",
"properties": {
"ipConfigurations": [{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}]
}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment