Skip to content

Instantly share code, notes, and snippets.

@jrudley
Created July 23, 2019 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrudley/58210b06884e8281c5d4859fbdff6e85 to your computer and use it in GitHub Desktop.
Save jrudley/58210b06884e8281c5d4859fbdff6e85 to your computer and use it in GitHub Desktop.
Learning to build ARM templates

How to build an ARM Template

This walkthrough will show you how to build an ARM template for a simple Azure Storage account resource.

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": []
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "storpersondemo",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"location": "East US",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"location": "East US",
"sku": "Standard_ZRS",
"name": "storpersonexample"
},
"resources": [
{
"name": "[variables('name')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "[variables('sku')]"
},
"kind": "StorageV2",
"location": "[variables('location')]",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string"
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_GRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS"
]
}
},
"variables": {
"location": "East US",
"name": "[concat(parameters('storagePrefix'), 'demothree')]"
},
"resources": [
{
"name": "[variables('name')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"location": "[variables('location')]",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string"
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_GRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS"
]
}
},
"variables": {
"storageName": "[concat(parameters('storagePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storageName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"location": "[resourceGroup().location]",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {
"storageId": {
"type": "string",
"value": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]"
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string"
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_GRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS"
]
}
},
"variables": {
"storageName": "[concat(parameters('storagePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storageName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"location": "[resourceGroup().location]",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {
"storageCredentials": {
"type": "object",
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2019-04-01')]"
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string"
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_GRS",
"allowedValues": [
"Standard_LRS",
"Standard_ZRS",
"Standard_GRS"
]
}
},
"variables": {
"storageName": "[concat(parameters('storagePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storageName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"location": "[resourceGroup().location]",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {
"storageKey": {
"type": "string",
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2019-04-01').keys[0].value]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment