Practical Tips And Tooling For Azure Resource Manager

Moving to Azure Resource Manager (ARM) can look daunting, especially when you are staring at a 1000+ line JSON ARM template that just failed deployment but once you get into it you will see it is not so bad. In this post I’m going to share some practical tips and tooling for Azure Resource Manager.

To read more about ARM and why you should use it instead of the classic Azure API take a look at this article for the official version. In my environment the main drivers for moving to ARM was RBAC and ARM deployment templates that make deployments to complex environments easier. Moving to ARM should not be an automatic decision just because it is new, you should evaluate the benefits first. At the time of writing this post there were no plans to discontinue the classic deployment model yet, so you still have time. That said for new projects I would suggest you use ARM and for existing ones look if you gain anything first before you migrate since it is not a trivial tasks for a large environment and a large script library.

Exploring The ARM API
If you use Azure PowerShell v1.0 or greater you will find the ARM cmdlets use the {verb}-AzureRM* naming convention to differentiate from the classic cmdlets, you can use Get-Help {cmdletname} -detailed to explore what each one does. If you use the Rest API directly you can use the ARM Explorer website to explore the Rest API against your own subscriptions. It is also useful to perform adhoc tasks if scripting is not necessary. ARM uses providers to manage the resources you can deploy, when you open ARM Explorer you can browse the list of providers registered with your subscription for example there are providers for computing, networking, websites etc.

Authoring ARM Templates
ARM templates make it easier to deploy complex environments using a declarative model to describe the resources that should be in the environment. The ARM deployment engine is clever enough to deploy the resources that are not there and to ignore the ones that exist already, it is like DSC for Azure. The templates are JSON and as we know, it is not the easiest thing to edit a large JSON document. Luckily you can use Visual Studio to make life easier, install the Azure SDK and add a new Azure Resource Group project to your solution. When you edit the JSON deployment templates and parameter files, there are schemas to validate the document, intellisense popups and the editor has some smarts around resources.

Practical Tips And Tooling For Azure Resource Manager

There is a large library of quick start templates on gitbub at this link. You can also export a template representing the resources currently in a resource group by opening the resource group in the portal and selecting export under the settings section, official block post here. This can also be accomplished from PowerShell using the Save-AzureRmResourceGroupDeploymentTemplate cmdlet.

Side Note: You can also use the ARMViz webapp to visualise and edit ARM templates.

Deploying ARM Templates
Deploying  your template is also easy, you right click on the project in Visual Studio and choose deploy. It will show a popup to choose the subscription, resource group, template and parameter files etc.

If you used the Visual Studio ARM project you will see it contains a PowerShell script called Deploy-AzureResourceGroup.ps1 that will run the ARM deployment.   The PowerShell command called New-AzureRmResourceGroupDeployment will run the deployment. If you want to validate your template you can use the Test-AzureRmResourceGroupDeployment command.

TroubleShooting Tips:

  • You can set the log level of the deployment and retrieve the detailed logs afterwards more here.
  • The Templates blade in the new portal can run ARM Templates and it performs more validation before executing and gives more descriptive error messages when failures occur than PowerShell or VisualStudio deployments.
  • You can view the audit logs and errors for your deployments in the Audit Logs blade in the new portal.

Francois Delport

Published by

Francois Delport

I am a cloud and devops consultant, technology fan and previously a professional C# developer with a keen interest in system design and architecture. Currently I am involved in projects using Azure, the Microsoft stack and DevOps. I am based in Melbourne, Australia. Email: [email protected]

Leave a Reply

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