Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
Last active September 20, 2016 19:38
Show Gist options
  • Select an option

  • Save gregjhogan/0c17daa326b5f9aa6945757962294380 to your computer and use it in GitHub Desktop.

Select an option

Save gregjhogan/0c17daa326b5f9aa6945757962294380 to your computer and use it in GitHub Desktop.
ARM template array lookup
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0",
"parameters": {
"vnet": {
"type": "string",
"defaultValue": "resource-group/vnet-name"
},
"ipAddress": {
"type": "string",
"defaultValue": ""
}
},
"variables": {
"convertToVnet": [
{
"resourceGroup": "[resourceGroup().name]",
"name": "[parameters('vnet')]"
},
{
"resourceGroup": "[split(parameters('vnet'),'/')[0]]",
"name": "[split(concat(parameters('vnet'),'/'),'/')[1]]"
}
],
"vnet": "[variables('convertToVnet')[sub(length(split(parameters('vnet'),'/')),1)]]",
"ipAddressHasValue": "[length(trim(parameters('ipAddress'), 1))]",
"convertToPrivateIpConfiguration": [
{
"privateIPAddress": null,
"privateIPAllocationMethod": "Dynamic"
},
{
"privateIPAddress": "[parameters('ipAddress')]",
"privateIPAllocationMethod": "Static"
}
],
"privateIpConfiguration": "[variables('convertToPrivateIpConfiguration')[variables('ipAddressHasValue')]]"
},
"resources": [],
"outputs": {
"vnet": {
"value": "[variables('vnet')]",
"type" : "object"
},
"privateIpConfiguration": {
"value": "[variables('privateIpConfiguration')]",
"type" : "object"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment