DevOps Basics: ARM Templates Part 2


Hello Folks,

Last week we discussed the composition of ARM Templates. A few days later I was contacted by a reader that pointed out that I forgot to explain how we can find the API versions needed for a specific resource types.

So I did some research, asked around internally and I found the answers ( Thanks to Keith Mayer – Thanks again buddy!  )

Resources

As we saw last week. The resources section of the ARM template is where you define the resources are deployed or updated when you deploy the template. There is a specific structure that you need to take care of when you define a resource.

Again as a reminder, each elements of the structure are defined below.

Element name

Required

Description

apiVersion

Yes

Version of the API that supports the resource.

type

Yes

Type of the resource. This value is a combination of the namespace of the resource provider and the resource type that the resource provider supports

name

Yes

Name of the resource. The name must follow URI component restrictions defined in RFC3986.

location

No

Supported geo-locations of the provided resource.

tags

No

Tags that are associated with the resource.

dependsOn

No

Resources that the resource being defined depends on. The dependencies between resources are evaluated and resources are deployed in their dependent order. When resources are not dependent on each other, they are attempted to be deployed in parallel. The value can be a comma separated list of a resource names or resource unique identifiers.

properties

No

Resource specific configuration settings.

resources

No

Child resources that depend on the resource being defined.

We already know that to find out all the types available, use PowerShell.  The following command

Get-AzureProvider –ListAvailable

image

But if you need to identify the proper apiVersion, you need to use another PowerShell Command.  For example, in the code snippet below taken from our template from the last post. If we needed to identify the proper apiVersion.

"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('newStorageAccountName')]",
"apiVersion": "2015-05-01-preview",
"location": "[variables('location')]",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},

You would now use the following command:

(Get-AzureProvider -ProviderNamespace Microsoft.Storage).ResourceTypes

And the results of that command will give you the apiVersion for each type.

PS C:\> (Get-AzureProvider -ProviderNamespace Microsoft.Storage).ResourceTypes

ResourceTypeName Locations ApiVersions
---------------- --------- -----------
storageAccounts {East US, East US 2, West US, West Europe...} {2015-05-01-preview, 2014-12-01-preview}
operations {} {2015-05-01-preview, 2014-12-01-preview}
checkNameAvailability {} {2015-05-01-preview, 2014-12-01-preview}
storageAccounts/services {East US, West US, East US 2 (Stage), West Europe...} {2014-04-01}
storageAccounts/services/metricDefinitions {East US, West US, East US 2 (Stage), West Europe...} {2014-04-01}


PS C:\>

in our example we’re defining Microsoft.Storage/storageAccounts therefore the valid apiVersion is 2015-05-01-preview

I hope this clarifies things.  if you need more info on any of the CANITPRO articles.  Drop us a line.  We’ll look into it for you.

Cheers!

Signature

Pierre Roman
@pierre.roman

Comments (0)

Skip to main content