Developing with Azure Resource Manager - Part 5 - Tip: Get all available api-version alternatives for the ARM endpoints

Introduction

I've worked with the Azure Resource Manager API's extensively over the last 6 months. While doing so I've realized that the API versions changes and there's new functionality available. In order to know what versions are out there (and to be sure that's the full truth, given the documentation on MSDN is suffering from a severe lag in updates...), there's a few tricks I'm doing to list all available versions of a provider in the ARM REST API endpoints.

Please note. This post assumes you've already got your ARM AAD apps set up and you're authenticated to use the API. If you want to see how to do that, check out the other posts in this series.

Get available Azure Resource Manager API Versions with REST

If you've already got nice routines for getting your data through REST, then there's a nice way to get the API versions available by simply listing all the providers. This is pretty straight forward:

https://management.azure.com/subscriptions/{subscription-id}/providers/{provider-name}?&api-version={api-version}

For example, a real query would look like this:

https://management.azure.com/subscriptions/87EBF366-F992-4B16-B96E-88E52F74F476/providers/Microsoft.Storage?api-version=2015-01-01

This would yield an output similar to this:

"id":"/subscriptions/SUBSCRIPTIONGUID/providers/Microsoft.Storage",
   "namespace":"Microsoft.Storage",
   "resourceTypes":[
      {
         <snipped...>
         "apiVersions":[
            "2016-01-01",
            "2015-06-15",
            "2015-05-01-preview"
         ]
      }
      <snipped...>
   ],
<snipped...>
}
JSON output of the api-version request

That's an easy way to get all the available versions for various endpoints in the API. You could make it more granular or make it broader, should you want to. If you are unsure about what providers you can request, you could just run this query to list all providers:

https://management.azure.com/subscriptions/87EBF366-F992-4B16-B96E-88E52F74F476/providers?api-version=2015-01-01

Get available Azure Resource Manager API Versions with PowerShell

Personally I like PowerShell a lot, and I'm a bit more keen on just opening a new session and getting my info this way, if I don't have any reason to pull up a full new web based REST request. The PowerShell cmdlets for Azure Resource Manager have had a facelift lately, and things are starting to look the better. Also, running this through PowerShell is very straight forward, and will give you only the versions as opposed to the full REST query I showed previously where you'd get all kinds of other data too (because I didn't have any filters on that).

Login with your Azure RM Account

Login-AzureRmAccount

It should get you logged in:

Now, we can run any type of PowerShell we want, and to get the versions for (in my case) the Microsoft.Web provider, this is what it would look like:

Update 2019-07-08: Mark Heath commented on this post with an update in the cmdlets. The code snippet has been updated accordingly below.
((Get-AzResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions

For reference, this is the old snippet where Get-AzureRmResourceProvider was used.

((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions

It should yield a result that looks something like this:

Enjoy.