The primary deployment model in azure is ARM or azure resource manager.ARM is responsible for deployment and management of azure resources.
You can deploy resources in azure using azure portal or using the ARM templates.ARM templates are JSON files which describes your resources.This is the way azure uses infrastructure as code.You specify all the resources you want to deploy in these JSON files.It consists of various sections.
The main sections in the ARM template are:
{ "$schema": -->required field ..points to json schema file "contentVersion": --> version of the deployment(e.g such as 1.0.0.0) "apiProfile": "" --> version of APIs "parameters": { } --> configurable values..these are passed to the template "variables": { } --> repeatable values.Variables are declared once and can be used multiple times in the template. "functions": [ ]-->user defined functions which are called from the template such as concat() "resources": [ ] --> resources which you want to deploy "outputs": { } --> the output from template execution }
You can create templates by following the above structure of the template file.For example here is a simple template to deploy a storage account :
{ "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2018-11-01", "name": "[variables('storageAccountName')]", "location": "[parameters('location')]", "sku": { "name": "Standard_LRS" }, "kind": "Storage", "properties": {} }
Usually you define parameters in a separate template file which is referenced in the main file.
Deploying templates
You can deploy templates using either powershell or azure cli.Following cli command will deploy a template defined in a template file calledĀ testgroup in a resource group called testgroup:
az group deployment create --resource-group testgroup--template-file C:\testgroup.json
Leave a Reply