Azure Availability Zones Mapping Checker

Microsoft is working hard to make “Availability Zones” available for most of their primary Azure regions. What is an Availability Zone will be covered later in another blog post, including why you should use it, what advantages it brings and more importantly (as most of the previous is covered by Microsoft documentation) – how do you migrate from your current non-AZ aware deployment into a fully redundant AZ zone deployment.

This will be a short post however. See the problem we will solve in this post is “which zone is which zone in another subscription”. Okay, that might need some explanation. Availability Zones are one or more datacenters that make up a zone. So, underlying it’s an actual physical datacenter with servers. But – instead of allocating for example AZ1 to those physical datacenters – the alignment of AZ’s inside a subscription can be different for another subscription. Or in short; AZ1 in subscription 1, might be AZ3 in subscription 2.

When you are deploying latency critical applications between zones (or you prefer to host all your services only in 1 zone and use another zone for your backups) you need to know the mapping of these zones for your subscriptions. Luckily Microsoft has made an API available that allows you to query the Zone Allocation between two subscriptions.

Prior to using the API, the feature needs to be registered which can be done using CLI, or PowerShell

CLI: az feature register -n AvailabilityZonePeering --namespace Microsoft.Resources
PowerShell: Register-AzProviderFeature -FeatureName AvailabilityZonePeering -ProviderNamespace Microsoft.Resources

To check on the registration status of the feature you can use:

CLI: az feature show -n AvailabilityZonePeering --namespace Microsoft.Resources
PowerShell: get-AzProviderFeature -FeatureName AvailabilityZonePeering -ProviderNamespace Microsoft.Resources

Next is obviously how you can query this API. Now many administrators/Devvers will know how to do this, but in case you don’t.. here’s a PowerShell script that works as well. The usage is pretty simple,

.\Check-AzureAZmapping.ps1 -Targetsubscription "7eac4c60-73b5-4c85-ab33-1234567" -location northeurope

You need to login to your source subscription – and you can optionally set -SourceSubscription in the command as well.

So, the output gives you on the left column the AZ for the SourceSubscription (or default AZContext you are in) and on the right you see the AZ zone that corresponds with the TargetSubscription. And as you can see, my source subscription AZ2 equals the target subscription AZ3 and vice versa.


I need to do some posts on AZ’s …

Oh wait.. the script

Tagged , ,