Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep resource API versions up to date on existing ARM template?

I have an existing Azure template that provisions the following resources

Microsoft.ClassicStorage/StorageAccounts (api version 2014-06-01)
microsoft.insights/components (api version 2014-08-01)

and some others ...

Using the code in the article Resource providers and types I found out that the resource API versions on my template are few versions behind:

Microsoft.ClassicStorage/StorageAccounts. Current: 2014-06-01, available:

2016-11-01
2016-04-01
2015-12-01
2015-06-01
2014-06-01
2014-04-01-beta
2014-04-01
2014-01-01

microsoft.insights/components. Current: 2014-08-01, available:

2015-05-01
2014-12-01-preview
2014-08-01
2014-04-01

Here are the questions that I have

  1. What is the best practice to maintain resource API versions in a template?
  2. Where do I learn about the changes introduced in each API version?
  3. What will Azure do if I change an API version on a resource that is already provisioned using the older API version?
like image 454
Alex S Avatar asked Jul 12 '17 15:07

Alex S


People also ask

Can ARM template update existing resource?

ARM template willnot recreate/overwrite the existing resource, if the resource is specified in the template. It will update the resource if the property values for a resource are changed.

What is API version in ARM template?

This API version corresponds to a version of REST API operations that are released by the resource provider (Microsoft.Compute/virtualMachines is the resource provider and namespace for virtual machines, Microsoft.Storage/storageAccounts is the resource provider and namespace for storage and storage accounts - as ...


1 Answers

Actually there is a way to always use the latest API Version. I do not recommend it but you can use:

[providers('<provider>','<type>').apiVersions[0]]

Here is a working example with a storage account:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "name": "uniquename",
            "apiVersion": "[providers('Microsoft.Storage','storageAccounts').apiVersions[0]]",
            "location": "West Europe",
            "sku": {
                "name": "Standard_LRS"
            },
            "kind": "Storage",
            "properties": {}
        }
    ]
}

I would prefer to use the most latest version when writing the ARM template and check for newer version when I encounter errors or I have to use some new features. I wrote two articles about how to determine latest API version for a resource provider and how to find outdated Azure ARM templates.

like image 132
Martin Brandl Avatar answered Oct 04 '22 10:10

Martin Brandl