Azure has moved towards the resource manager (ARM) model for all new versions. Both the new portal and AzureRM PowerShell use ARM. The templates are based on JSON (Javascript Object Notation) and allow for incremental and idempotent deployments, so when an error occurs, you can fix and re-deploy without affecting existing resources.

Using a simple JSON file you deploy any number of resources into a resource group. The simplest version of such a file is the following. Note that Microsoft Docs actually leaves out the contentVersion parameters which is required.

{
   "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
   "contentVersion": "1.0.0.0",
   "parameters": {  },
   "variables": {  },
   "resources": [  ],
   "outputs": {  }
}

There are five properties you can edit. Required are contentVersion , resources  and $schema .

Use the contentVersion parameter to distinguish different versions of the template. Parameters contains questions the user has to answer when deploying the file. Variables are re-usable JSON fragments.

The resources property contains the collection of resources you want to deploy.

It is possible to execute a hierarchy of template files. In this case you can use the outputs property to pass data back to a parent file.

Deploying the file

ARM template are deployed into a resource group. You may want to create one for test purposes which you can delete afterwards.

New-AzureRmResourceGroup -Name Demo -Location "West Europe"

Deleting a resource group will deleted all resources it contains. Not only the ones you deploy via the script.

Remove-AzureRmResourceGroup -Name Demo

Next you can validate the template file.

Test-AzureRmResourceGroupDeployment -ResourceGroupName Demo -TemplateFile demo.json

Then deploy the file to the specific Azure resource group.

New-AzureRmResourceGroupDeployment -Name DemoDeployment -ResourceGroupName Demo -TemplateFile demo.json

Instead of -TemplateFile  you can also use -TemplateUri  and provide a URI to the file.

Visualizing the file

Microsoft is developing an online editor and visualizer for ARM templates at armviz.io. It’s still in its infancy at the time of writing.

Checking the deployment status

Depending on the size of your file the deployment may take a while to complete. For any deployment you can check the status for the resource group.