Resolving Azure ARM REST API Versions Conflict In ARM Templates


This post is from Premier Developer consultant Adel Ghabboun.


Usually if you use the Azure Portal Automation Script feature to generate an ARM template and copy that to a new Visual Studio Azure Resource Group project, Visual Studio editor will complain about the API version that is used in the template and suggest a new version. It looks like this:

clip_image001

If you click Ctrl + Space, Visual Studio will show you all the possible values:

clip_image002

Now, if you change the value and try to deploy this template to your Azure resource group, the result will come back failed with a deployment error:

"error": {
"code": "NoRegisteredProviderFound",
"message": "No registered resource provider found for location 'eastus' and API version '2016-08-01' for type 'components'. The supported api-versions are '2014-04-01, 2014-08-01, 2015-05-01, 2014-12-01-preview'.

Now, which one should we use?

Let’s look at the PowerShell Azure SDK command Get-AzureRMResourceProvider to retrieve the API version information by following the below steps (Note that Azure SDK must be installed on your machine prior to running the Azure commands below, See Install and Configure Azure PowerShell ):

  1. Open Windows PowerShell ISE in Admin Mode
  2. Run this command to login to your Azure Account
    Login-AzureRmAccount
  3. Login to your account using your Azure credentials
  4. Run the following command (Assuming Application Insights is the resource we want to create)
    (Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Insights).ResourceTypes | Where {$_.ResourceTypeName -eq 'components'} | Select -ExpandProperty ApiVersions
    2015-05-01
    2014-12-01-preview
    2014-08-01
    2014-04-01

Now, using the API version that is provided by the PowerShell command will solve the issue.

Conclusion:

As a best practice and to avoid any deployment issue regardless if you are using Visual Studio or other tools to deploy your Azure templates, always run the PowerShell command mentioned above to retrieve the API versions information and use the latest one.

Comments (4)

  1. Andrew says:

    Thanks for sharing this one. ARM templates are a bit of a mystery to most of us still so am sure this one will save a lot of people time.

    The azure portal Automation Script is a great gateway drug but the more knowledge out there on best practices around this the better.

    Configuration in declarative file format is still pretty new in the .Net / Azure space for to of the world.

    1. AdelGhabboun says:

      Yes Andrew, I agree. Please click on this link and take a look at some ARM templates best practices https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-template-best-practices

      Hope it helps 🙂

  2. Thanks for sharing, the truth is that I did not quite understand the templates, but with your help now I see it easier.

    Thanks and good job

    1. AdelGhabboun says:

      Gomez, I am glad it helped 🙂

Skip to main content