Last active
September 20, 2016 19:38
-
-
Save gregjhogan/0c17daa326b5f9aa6945757962294380 to your computer and use it in GitHub Desktop.
ARM template array lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$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