Azure Resource Manager Template
- ARM templates are JSON files that define the infrastructure and configuration for your deployment.
- They use a declarative syntax
- They allow you to automate deployments.
- Have built-in validation. It checks the template before starting the deployment to make sure it succeeds
File structure
Section titled “File structure”schema -> Defines the location of the JSON file that describes the structure of the JSON data.
contentVersion -> Defines the version of the template. Initially is usually set to 1.0.0.0, you can change it to document significant changes.
apiProfile -> Optional. Defines a collection of API versions for resource types.
parameters -> Optional. Section where you define values that are provided during deployment
variables -> Optional. Section where you define values that are used to simplify template language expressions
functions -> Optional. Section where you can define user-defined functions that are available within the template
resources -> Section that defines the actual items you want to deploy or update.
output -> Optional section where you specify the values that are returned at the end of the deployment
Deploy an ARM template
Section titled “Deploy an ARM template”Sign in
az loginCreate a new resource group
az group create \ --name {name of your resource group} --location "{location}"Define a default group
az configure --defaults group="<resource-group-name>"Deploy the IaC file
templateFile="{provide-the-path-to-the-template-file}"
az deployment group create \ --name blanktemplate \ --resource-group myResourceGroup \ --template-file $templateFileAnother way (if a default group is defined):
templateFile="azuredeploy.json"today=$(date +"%d-%b-%Y")DeploymentName="blanktemplate-"$today
az deployment group create \ --name $DeploymentName \ --template-file $templateFileThe date is optional
A deployment group es un registro histórico del despliegue
Ese registro guarda:
-
Quién ejecutó el despliegue.
-
A qué hora y en qué fecha se lanzó.
-
Qué parámetros se usaron.
-
Si el despliegue tuvo éxito o en qué recurso exacto dio error.
A CI/CD pipeline automates the automates the creation and deployment
Regions
Section titled “Regions”Spain Central -> spaincentral West Europe -> westeurope North Europe -> northeurope France Central -> francecentral Germany West Central -> germanywestcentral UK South -> uksouth
Resource Groups commands
List all groups
az group list --output tableDelete a Resource Group
az group delete --name rg-az104-labDelete a Resource Group in second plane without confirmation
az group delete --name rg-az104-lab --no-wait --yes