- Part 0: Introduction to the article series
- Part 1: Create an AzureRm Active Directory (AAD) Application using PowerShell
- Part 2: Getting started with the AzureRm PowerShell cmdlets
- Part 3: Build an application using C# which is using the Azure Resource Manager API's
- Part 4: Tip: Azure Resource Explorer Tool
- Part 5: Tip: Get all available api-version alternatives for the ARM endpoints
- Part 6: Move Azure Resources from one Resource Group to another
- Part 7: Download an Azure Publishing Profile (xml) programmatically using REST
- Part 8: Programmatically export Resource Group template using the REST API
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:
For example, a real query would look like this:
This would yield an output similar to this:
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:
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
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: