Finding ARM template ApiVersion

Writing an Azure ARM template for a Resource Group is getting easier every day but it remains a sport for the initiated.

Here I want to give a tip about something I often find hard:  how to get the API version of a resource in an ARM template?

As everything hardcore in the platform, we’ll use PowerShell!

The example I’ll use today is creating a backup vault using ARM.

Login

As usual, please do login in PowerShell Integrated Scripting Environment (ISE) with the usual command Login-AzureRmAccount.

Find your provider

First you need to find the provider for the resource you want to create.

For that, use Get-AzureRmResourceProvider.  This will return the list of all available providers.

image

For me, since I’m looking for the backup vault, the Microsoft.Backup provider seems promissing.

The following will give you all the resource types under the provider (in this case only one):

[code language=”PowerShell”]

(Get-AzureRmResourceProvider -ProviderNamespace "Microsoft.Backup").ResourceTypes

[/code]

image

You see already that we get very valuable information here.  We get the API versions I was looking for but also the Azure regions where the resources are available.

ARM Template

Once you know the Api Version it is much easier to create the arm template.  In the case of my backup vault:

[code language=”javascript”] {       "name": "AdvVault-cp",       "type": "Microsoft.Backup/BackupVault",       "apiVersion": "2015-03-15",       "location": "[resourceGroup().location]",       "tags": { },       "properties": {         "sku": {           "name": "[parameters(‘skuName’)]"         }       } } [/code]

Conclusion

There really is a wealth of information you can undig by using just a few Azure PowerShell cmdlets.

One of the tricky part when you reverse engineer an ARM template starting from the Resource Explorer in the portal is to find the API version which you can get with a few cmd lets as demonstrated here.


Leave a comment