All about Azure Resource Manager and Templates

All about Azure Resource Manager and Templates

All about Azure Resource Manager and Templates

Azure Resource Manager, sometimes referred as Version 2 of Microsoft Azure, is a next version of Azure Service Manager (referred as Version 1). Azure Resource Manager (ARM) ties together Compute, Storage and Network and shows them as a single unit that can be created, updated and deleted together. This is easy for managing the resources and for billing purposes.

Below are the some of the key points to remember on ARM –

  • Supports templates based Azure resource deployment
  • Supports tagging for logical mapping of resources
  • Supports resources in multiple regions
  • Virtual Machines can connect to Network created in local region
  • VNet-VNet communication is supported using gateways even for Virtual Networks in same region
  • ARM templates will be common in Azure Hybrid deployments (Azure and Azure Stack) providing seamless experience to developers and IT administrators
  • Virtual Machines created on Azure Service Manager (ASM), can’t be migrated to Azure Resource Manager as yet. This may be supported in future
  • ARM supports deploying resources using new coding language called JSON
  • Each Resource can exist only in one Resource Group
  • Resources can be moved between Resource Groups

Azure Resource Manager URL –

ARM Templates

Azure Resource Manager supports template based Azure Resource deployment as stated above. This results in rapid, consistent and standardized deployment of Azure Resources. Typical Azure resources contain IaaS (Virtual Machines), Virtual Networks, PaaS resources like Web Apps and Database. All of these can be easily provisioned rapidly  by Azure Resource Manager.

Editor for Azure Resource Manager Templates

Typically Visual Studio is considered to be most recommended or trusted editor for ARM templates but it requires licensing and if you don’t have Visual Studio license then you could also use free JSON viewer for Notepad++. Not a best choice but works well to read the existing JSON templates and modify them according to your need.

JSON Viewer for Notepad++ –

JSON Editor –

JSON Validator –

Syntax – ARM Templates

As explained earlier, ARM templates are JSON based and typically contains 4 sections, shows below –

  1. Parameters – Contains parameters that can be entered during run-time with set of values or default values pre-defined.
  2. Variables – Contains Variables that are static in the code and will be used for deploying resources.
  3. Resources – Contains resources to be deployed
  4. Output – Displays output on the screen

How to get started

If you are a native PowerShell user and wants to write JSON based ARM templates then you would find coding easy but Syntax bit unclean (at least I was not comfortable with JSON way of defining variables and resources). You must go through some sample templates for IaaS, PaaS, networking etc. and start making changes as you need and get familiarized.

Github contains many Azure-quickstart-templates and they should be the ideal choice for reference. Not to forget to use the Visual Studio or Notepad++ JSON viewer to understand the template else you might get lost in the way JSON was written.

Browse GitHub Azure Quick Start Templates

Executing with PowerShell

First you need to install Azure PowerShell – Read this article to install Azure PowerShell. Once installed, launch Azure PowerShell and execute

Login-AzureRMAccount – to login into your Azure Subscription and access Azure RM resource commands.

Some useful commands are listed below that will be handy while writing ARM templates –

List available Resource Providers

Get-AzureRmResourceProvider -ListAvailable

Get supported locations for a SQL Resource Provider

((Get-AzureRmResourceProvider -ProviderNameSpace Microsoft.Sql).ResourceTypes | where-object ResourceTypeName -eq servers).Locations

Get API Versions of a Resource Provider

((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions

Create a New Resource Group

New-AzureRmResourceGroup -Name MyNewResourceGroup -Location "East Asia"

Deploy ARM Template

New-AzureRmResourceGroupDeployment -ResourceGroupName MyNewResourceGroup -TemplateFile C:\SarveshARM\Templates\NewSampleVM.json

Deploy ARM Template with dynamic Parameters

PS C:\> New-AzureRmResourceGroupDeployment -ResourceGroupName MyNewResourceGroup -TemplateFile C:\SarveshARM\Templates\NewSampleVM.json -hostingPlanName freeplaneast -serverName testserver -administratorLogin testadmin

You will be prompted for password (as Secure String) depending on ARM template.

Move a Resource to another Resource Group

$resource = Get-AzureRmResource -ResourceName ExampleApp -ResourceGroupName OldRG
Move-AzureRmResource -DestinationResourceGroupName NewRG -ResourceId $resource.ResourceId

Remove a Resource from Resource Group

Remove-AzureRmResource -Name NewSampleVM -ResourceGroupName MyNewResourceGroup -ApiVersion 2015-08-01

Delete a Resource Group

Remove-AzureRmResourceGroup -Name MyNewResourceGroup

Troubleshoot Deployment

(Get-AzureRmResourceGroupDeploymentOperation -DeploymentName TestDeployment -ResourceGroupName TestGroup).Properties.StatusMessage

This is just a beginning on ARM Templates.

Next Steps

I recommend to go to GitHub and refer some sample ARM templates and based on your test scenarios try to automate the Azure Resource Deployments. The more you try and the more you would know merits of using Azure Resource Manager and its templates.

Please drop comments if you have liked this article or have any question.


About The Author

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *