├── numeric ├── _float.json ├── add.json ├── div.json ├── mod.json ├── mul.json ├── sub.json ├── max.json ├── min.json ├── int.json └── copyIndex.json ├── logical ├── bool.json ├── if.json ├── not.json ├── or.json └── and.json ├── string ├── base64.json ├── last.json ├── dataUri.json ├── first.json ├── guid.json ├── indexOf.json ├── endsWith.json ├── concat.json ├── contains.json ├── lastIndexOf.json ├── startsWith.json ├── uniqueString.json ├── uri.json ├── dataUriToString.json ├── string.json ├── uriComponent.json ├── empty.json ├── skip.json ├── take.json ├── length.json ├── padLeft.json ├── split.json ├── toLower.json ├── toUpper.json ├── trim.json ├── replace.json ├── substring.json ├── base64ToString.json ├── base64ToJson.json └── uriComponentToString.json ├── comparison ├── less.json ├── equals.json ├── greater.json ├── lessOrEquals.json └── greaterOrEquals.json ├── array-and-object ├── range.json ├── json.json ├── createArray.json ├── empty.json ├── max.json ├── min.json ├── array.json ├── length.json ├── first.json ├── last.json ├── contains.json ├── skip.json ├── take.json ├── coalesce.json ├── union.json ├── concat.json └── intersection.json ├── resource ├── _listKeys.json ├── subscription.json ├── resourceGroup.json ├── _resouceId.json ├── _reference.json └── providers.json ├── deployment-value ├── deployment.json ├── variables.json └── parameters.json ├── README.md └── AzTemplateFunctions.psm1 /numeric/_float.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": {} 13 | } -------------------------------------------------------------------------------- /logical/bool.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "boolOutput": { 14 | "value": "[bool('true')]", 15 | "type": "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /logical/if.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "ifOutput": { 14 | "type": "string", 15 | "value": "[if(equals('a', 'a'), 'yes', 'no')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/add.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "addResult": { 14 | "type": "int", 15 | "value": "[add(5, 3)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/div.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "divOutput": { 14 | "type": "int", 15 | "value": "[div(12, 3)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "modOutput": { 14 | "type": "int", 15 | "value": "[mod(7, 3)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/mul.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "mulOutput": { 14 | "type": "int", 15 | "value": "[mul(3, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/sub.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "subOutput": { 14 | "type": "int", 15 | "value": "[sub(7, 3)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/base64.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "base64Output": { 14 | "value": "[base64('stringToEncode')]", 15 | "type" : "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /comparison/less.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "lessOutput": { 14 | "type": "bool", 15 | "value": "[less(4, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/max.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "maxOutput": { 14 | "type": "int", 15 | "value": "[max(0,3,2,5,4)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /numeric/min.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "minOutput": { 14 | "type": "int", 15 | "value": "[min(0,3,2,5,4)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /logical/not.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "notOutput": { 14 | "value": "[not(bool('true'))]", 15 | "type": "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /array-and-object/range.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "rangeOutput": { 14 | "type": "array", 15 | "value": "[range(5,3)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /comparison/equals.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "equalsOutput": { 14 | "type": "bool", 15 | "value": "[equals(5, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /comparison/greater.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "greaterOutput": { 14 | "type": "bool", 15 | "value": "[greater(6, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /resource/_listKeys.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "resources": [], 11 | "outputs": { 12 | "referenceOutput": { 13 | "type": "object", 14 | "value": "[listKeys(parameters('storageAccountName'), '2016-12-01')]" 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /string/last.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "lastOutput": { 14 | "type": "string", 15 | "value": "[last('One Two Three')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /logical/or.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "orOutput": { 14 | "value": "[or(bool('true'), bool('false'))]", 15 | "type": "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/dataUri.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "dataUriOutput": { 14 | "value": "[dataUri('stringToTest')]", 15 | "type" : "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/first.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "firstOutput": { 14 | "type": "string", 15 | "value": "[first('One Two Three')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/guid.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "guidOutput": { 14 | "value": "[guid(resourceGroup().id)]", 15 | "type": "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/indexOf.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "indexOfOutput": { 14 | "value": "[indexOf('test', 't')]", 15 | "type" : "int" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /array-and-object/json.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "jsonOutput": { 14 | "type": "object", 15 | "value": "[json('{\"a\": \"b\"}')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /logical/and.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "andOutput": { 14 | "value": "[and(bool('true'), bool('false'))]", 15 | "type": "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/endsWith.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "endsWidthOutput": { 14 | "value": "[endsWith('abcdef', 'ef')]", 15 | "type" : "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /comparison/lessOrEquals.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "lessOrEqualsOutput": { 14 | "type": "bool", 15 | "value": "[lessOrEquals(5, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /deployment-value/deployment.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "deploymentOutput": { 14 | "value": "[deployment()]", 15 | "type" : "object" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /resource/subscription.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "subscriptionOutput": { 14 | "value": "[subscription()]", 15 | "type" : "object" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/concat.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "concatOutput": { 14 | "value": "[concat('text1', '-', 'text2')]", 15 | "type" : "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "containsOutput": { 14 | "type": "bool", 15 | "value": "[contains('stringToTest', 'e')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/lastIndexOf.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "lastIndexOfOutput": { 14 | "value": "[lastIndexOf('test', 't')]", 15 | "type" : "int" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/startsWith.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "startsWithOuput": { 14 | "value": "[startsWith('abcdef', 'ab')]", 15 | "type" : "bool" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /comparison/greaterOrEquals.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "greaterOrEqualsOutput": { 14 | "type": "bool", 15 | "value": "[greaterOrEquals(5, 5)]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /resource/resourceGroup.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "resourceGroupOutput": { 14 | "value": "[resourceGroup()]", 15 | "type" : "object" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /array-and-object/createArray.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "creatArrayOutput": { 14 | "type": "array", 15 | "value": "[createArray('a', 'b', 'c')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /deployment-value/variables.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": { 11 | "testString":"test" 12 | }, 13 | "resources": [], 14 | "outputs": { 15 | "variablesOutput":{ 16 | "type": "string", 17 | "value": "[variables('testString')]" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /string/uniqueString.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "uniqueStringOutput": { 14 | "value": "[uniqueString(resourceGroup().id)]", 15 | "type" : "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/uri.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "uriOutput": { 14 | "type": "string", 15 | "value": "[uri('http://contoso.com/resources/', 'nested/azuredeploy.json')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /resource/_resouceId.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "resourceIdOutput":{ 14 | "type": "string", 15 | "value": "[resourceId('Microsoft.Storage/storageAccounts',parameters('storageAccountName'))]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /string/dataUriToString.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "dataUriToStringOutput": { 14 | "type": "string", 15 | "value": "[dataUriToString('data:;base64,SGVsbG8sIFdvcmxkIQ==')]" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /resource/_reference.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": {}, 11 | "resources": [], 12 | "outputs": { 13 | "BlobUri": { 14 | "value": "[reference(concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '2016-01-01').primaryEndpoints.blob]", 15 | "type" : "string" 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /deployment-value/parameters.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString":{ 10 | "type": "string", 11 | "defaultValue": "test" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "parametersOutput":{ 18 | "type": "string", 19 | "value": "[parameters('testString')]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /numeric/int.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "4" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "intOutput": { 18 | "type": "int", 19 | "value": "[int(parameters('testString'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testInt": { 10 | "type": "int", 11 | "defaultValue": 5 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "stringOutput": { 18 | "type": "string", 19 | "value": "[string(parameters('testInt'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/uriComponent.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": { 11 | "uri": "[uri('http://contoso.com/resources/', 'nested/azuredeploy.json')]" 12 | }, 13 | "resources": [], 14 | "outputs": { 15 | "uriComponentOutput": { 16 | "type": "string", 17 | "value": "[uriComponent(variables('uri'))]" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /string/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "emptyOutput": { 18 | "type": "bool", 19 | "value": "[empty(parameters('testString'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [] 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "emptyOutput": { 18 | "type": "bool", 19 | "value": "[empty(parameters('testArray'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/max.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [0,3,2,5,4] 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "maxOutput": { 18 | "type": "int", 19 | "value": "[max(parameters('testArray'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/min.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [0,3,2,5,4] 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "minOutput": { 18 | "type": "int", 19 | "value": "[min(parameters('testArray'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/array.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "a" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "arrayOutput": { 18 | "type": "array", 19 | "value": "[array(parameters('testString'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/skip.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "one two three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "stringOutput": { 18 | "type": "string", 19 | "value": "[skip(parameters('testString'),5)]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/take.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "one two three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "stringOutput": { 18 | "type": "string", 19 | "value": "[take(parameters('testString'),5)]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/length.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [ 12 | "one", 13 | "two", 14 | "three" 15 | ] 16 | } 17 | }, 18 | "variables": {}, 19 | "resources": [], 20 | "outputs": { 21 | "lengthOutput": { 22 | "type": "int", 23 | "value": "[length(parameters('testArray'))]" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /string/length.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "stringToTest": { 10 | "type": "string", 11 | "defaultValue": "One Two Three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "lengthOutput": { 18 | "type": "int", 19 | "value": "[length(parameters('stringToTest'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/padLeft.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "123" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "padLeftOuput": { 18 | "type": "string", 19 | "value": "[padLeft(parameters('testString'),10,'0')]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/split.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "one,two,three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "splitOutput": { 18 | "type": "array", 19 | "value": "[split(parameters('testString'),',')]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/toLower.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "One Two Three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "toLowerOutput": { 18 | "value": "[toLower(parameters('testString'))]", 19 | "type": "string" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/toUpper.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "One Two Three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "toUpperOutput": { 18 | "type": "string", 19 | "value": "[toUpper(parameters('testString'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/trim.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": " one two three " 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "trimOutput": { 18 | "type": "string", 19 | "value": "[trim(parameters('testString'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/first.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": ["one", "two", "three"] 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "firstOutput": { 18 | "type": "string", 19 | "value": "[first(parameters('testArray'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/last.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": ["one", "two", "three"] 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "lastOutput": { 18 | "type": "string", 19 | "value": "[last(parameters('testArray'))]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/replace.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "123-123-1234" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "replaceOutput": { 18 | "type": "string", 19 | "value": "[replace(parameters('testString'),'-', '')]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/substring.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testString": { 10 | "type": "string", 11 | "defaultValue": "one two three" 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "substringOutput": { 18 | "value": "[substring(parameters('testString'), 4, 3)]", 19 | "type": "string" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /array-and-object/contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testObject": { 10 | "type": "object", 11 | "defaultValue": {"one": "a", "two": "b", "three": "c"} 12 | } 13 | }, 14 | "variables": {}, 15 | "resources": [], 16 | "outputs": { 17 | "containsOutput": { 18 | "type": "bool", 19 | "value": "[contains(parameters('testObject'), 'one')]" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /string/base64ToString.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "string": { 10 | "type": "string", 11 | "defaultValue": "one, two, three" 12 | } 13 | }, 14 | "variables": { 15 | "base64String": "[base64(parameters('string'))]" 16 | }, 17 | "resources": [], 18 | "outputs": { 19 | "base64ToStringOutput": { 20 | "type": "string", 21 | "value": "[base64ToString(variables('base64String'))]" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /array-and-object/skip.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [ 12 | "one", 13 | "two", 14 | "three" 15 | ] 16 | } 17 | }, 18 | "variables": {}, 19 | "resources": [], 20 | "outputs": { 21 | "skipOutput": { 22 | "type": "array", 23 | "value": "[skip(parameters('testArray'),1)]" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /string/base64ToJson.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "jsonString": { 10 | "type": "string", 11 | "defaultValue": "{'one': 'a', 'two': 'b'}" 12 | } 13 | }, 14 | "variables": { 15 | "base64Object": "[base64(parameters('jsonString'))]" 16 | }, 17 | "resources": [], 18 | "outputs": { 19 | "base64ToJsonOutput": { 20 | "type": "object", 21 | "value": "[base64ToJson(variables('base64Object'))]" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /string/uriComponentToString.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": { 11 | "uri": "[uri('http://contoso.com/resources/', 'nested/azuredeploy.json')]", 12 | "uriComponent": "[uriComponent(variables('uri'))]" 13 | }, 14 | "resources": [], 15 | "outputs": { 16 | "uriComponentToStringOutput": { 17 | "type": "string", 18 | "value": "[uriComponentToString(variables('uriComponent'))]" 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /array-and-object/take.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testArray": { 10 | "type": "array", 11 | "defaultValue": [ 12 | "one", 13 | "two", 14 | "three" 15 | ] 16 | } 17 | }, 18 | "variables": {}, 19 | "resources": [], 20 | "outputs": { 21 | "takeOutput": { 22 | "type": "array", 23 | "value": "[take(parameters('testArray'),2)]" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /numeric/copyIndex.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | } 9 | }, 10 | "variables": { 11 | "object": { 12 | "copy": [ 13 | { 14 | "name": "items", 15 | "count": 3, 16 | "input": { 17 | "name": "[concat('myItem', copyIndex('items'))]", 18 | "index": "[copyIndex('items')]" 19 | } 20 | } 21 | ] 22 | } 23 | }, 24 | "resources": [], 25 | "outputs": { 26 | "copyIndexOutput":{ 27 | "value": "[variables('object')]", 28 | "type": "object" 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /array-and-object/coalesce.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "testObject": { 10 | "type": "object", 11 | "defaultValue": { 12 | "null1": null, 13 | "string": "default" 14 | } 15 | } 16 | }, 17 | "variables": {}, 18 | "resources": [], 19 | "outputs": { 20 | "coalesceOutput": { 21 | "type": "array", 22 | "value": "[coalesce(parameters('testObject').null1, parameters('testObject').array)]" 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /array-and-object/union.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "array1": { 10 | "type": "array", 11 | "defaultValue": ["one", "two", "three"] 12 | }, 13 | "array2": { 14 | "type": "array", 15 | "defaultValue": ["three", "four"] 16 | } 17 | }, 18 | "variables": {}, 19 | "resources": [], 20 | "outputs": { 21 | "unionOutput": { 22 | "type": "array", 23 | "value": "[union(parameters('array1'), parameters('array2'))]" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /array-and-object/concat.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "array1": { 10 | "type": "array", 11 | "defaultValue": [ 12 | "1a", 13 | "1b", 14 | "1c" 15 | ] 16 | }, 17 | "array2": { 18 | "type": "array", 19 | "defaultValue": [ 20 | "2a", 21 | "2b", 22 | "2c" 23 | ] 24 | } 25 | }, 26 | "variables": {}, 27 | "resources": [], 28 | "outputs": { 29 | "concatOutput": { 30 | "type": "array", 31 | "value": "[concat(parameters('array1'), parameters('array2'))]" 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /resource/providers.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "providerNamespace": { 10 | "type": "string", 11 | "defaultValue": "Microsoft.Storage" 12 | }, 13 | "resourceType": { 14 | "type": "string", 15 | "defaultValue": "storageAccounts" 16 | } 17 | }, 18 | "resources": [], 19 | "outputs": { 20 | "providerOutput": { 21 | "value": "[providers(parameters('providerNamespace'), parameters('resourceType'))]", 22 | "type" : "object" 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /array-and-object/intersection.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "storageAccountName": { 6 | "type": "string", 7 | "defaultValue": "armtemplatefunctions" 8 | }, 9 | "object1": { 10 | "type": "object", 11 | "defaultValue": {"one": "a", "two": "b", "three": "c"} 12 | }, 13 | "object2": { 14 | "type": "object", 15 | "defaultValue": {"one": "a", "two": "z", "three": "c"} 16 | } 17 | }, 18 | "variables": {}, 19 | "resources": [], 20 | "outputs": { 21 | "interSectionOutput": { 22 | "type": "object", 23 | "value": "[intersection(parameters('object1'), parameters('object2'))]" 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Test Azure Resource Manager template functions 2 | 3 | Azure Resource Manager templates can contain template functions. New template functions will always be introduced in global Azure first, and subsequently amde available in the sovereign clouds and Azure Stack. It is currently not possible to list the available template functions in an given Azure Resource Manager instance. 4 | 5 | This repository contains a PowerShell module that will test a series of Azure Resource Manager templates. Each template contains a template functions. The result of the tests will list what template functions are available in an Azure Resource Manager instance. 6 | 7 | ## Prerequisites 8 | 9 | - Install Azure PowerShell ([Azure](https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps), [Azure Stack](https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-powershell-install)) 10 | - Connect to Azure Resource Manager ([Azure](https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps), [Azure Stack](https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-powershell-configure-user)) 11 | 12 | ## Run test 13 | 14 | After connecting to Azure Resource Manager, use the same PowerShell session to run the tests 15 | 16 | ``` PowerShell 17 | cd \ 18 | 19 | # Download the repository content 20 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 21 | invoke-webrequest https://github.com/marcvaneijk/arm-template-functions/archive/master.zip -OutFile .\master.zip 22 | 23 | # Expand the downloaded zip file 24 | expand-archive master.zip -DestinationPath . -Force 25 | 26 | 27 | # Change to the module directory and import the module 28 | cd arm-template-functions-master 29 | Import-Module .\AzureRmTemplateFunctions.psm1 30 | 31 | # Run the tests 32 | Test-AzTemplateFunctions -Path .\ -Location 33 | ``` 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /AzTemplateFunctions.psm1: -------------------------------------------------------------------------------- 1 | # Connect to your Azure environment with PowerShell 2 | # Select the desired subscritpion 3 | 4 | 5 | function Test-AzTemplateFunctions { 6 | [cmdletbinding()] 7 | Param ( 8 | [string]$Path, 9 | [string]$Location 10 | ) 11 | BEGIN { 12 | 13 | # Create Resource Group 14 | $Guid = ([guid]::NewGuid()).guid 15 | 16 | $Exists = Get-AzResourceGroup -Name $Guid -Location $Location -ErrorAction SilentlyContinue   17 | If ($Exists){  18 | Write-Error "Resource Group already exists"   19 | Break 20 | }   21 | Else {   22 | Write-Verbose "Creating Resource Group..." -Verbose 23 |       $rg = New-AzResourceGroup -Name $Guid -Location $Location 24 | }  25 | 26 | # Create Storage Account 27 | $StorageAccountName = 'armtf' + $Guid.replace('-','').subString(0,18) 28 | 29 | Write-Verbose "Creating Storage Account. This can take a moment..." -Verbose 30 | $sa = New-AzStorageAccount -Name $StorageAccountName -ResourceGroupName $Guid -Location $Location -SkuName Standard_LRS -Verbose 31 | 32 | } 33 | PROCESS { 34 | 35 | $result = @() 36 | 37 | # Get Deployment Templates 38 | $templateFunctions = get-childitem $path -File -Filter *.json -Recurse 39 | 40 | # Initialize counter for Progress Bar 41 | $count = 1 42 | $percentage = 100/$templateFunctions.count 43 | 44 | # Initialize parameter object for template deployment 45 | $templateParameterObject = @{ 46 | storageAccountName = $StorageAccountName 47 | } 48 | 49 | ForEach ($function in $templateFunctions) { 50 | 51 | $test = New-Object -TypeName PSObject 52 | $test | Add-Member -Type NoteProperty -Name type -Value $function.Directory.Name 53 | $test | Add-Member -Type NoteProperty -Name templateFunction -Value $function.BaseName 54 | 55 | try{ 56 | $DebugPreference = 'Continue' 57 | $output = Test-AzResourceGroupDeployment -ResourceGroupName $Guid -TemplateFile $function.FullName -TemplateParameterObject $templateParameterObject 5>&1 -ErrorAction SilentlyContinue 58 | $DebugPreference = 'SilentlyContinue' 59 | $message = ($output | Where-Object { $_ -like "*HTTP RESPONSE*"}).Message 60 | $start = $message.IndexOf('Status Code:')+14 61 | $end = $message.substring($start).IndexOf('Headers:')-4 62 | 63 | $test | Add-Member -Type NoteProperty -Name result -Value $message.substring($start,$end) 64 | } 65 | catch{ 66 | $test | Add-Member -Type NoteProperty -Name result -Value "Failed" 67 | } 68 | 69 | $result += $test 70 | 71 | Write-Progress -Activity "Testing template function $count of $($templateFunctions.count)" -Status "$($function.Directory.Name + ' | ' + $function.BaseName)" -PercentComplete ($percentage*$count) 72 | $count = $count+1 73 | } 74 | } 75 | END { 76 | Write-Verbose "Deleting temporary resource group and storage account. This can take a moment..." -Verbose 77 | Remove-AzResourceGroup -Name $Guid -Force | Out-Null 78 | 79 | return $result 80 | } 81 | 82 | } 83 | --------------------------------------------------------------------------------