DEV Community

Martin Humlund Clausen
Martin Humlund Clausen

Posted on

Investigating Azure Regional Capabilities

This week, I was tasked with figuring out whether we could support a new region on our company’s hosting platform.

I started by searching the web for information on Azure capabilities in a specific region. Before I knew it, I had spent an hour combing through resources. The only useful document I could find was a huge, 50-page PDF filled with slick layouts, graphics, and all the marketing fluff you can imagine. While the PDF did contain some technical information, I quickly realised it would take forever to compare the resources in the document with those from an existing region we were already using.

It was time to switch up my approach.

I decided to explore the Azure CLI to see if I could query regions and their capabilities directly. Sometimes when you ask the universe for answers, it delivers. After a bit of planning, I came up with the following approach:

  1. First, we need to list the current capabilities in an existing region to get a list of resourceType we require.
  2. Then, we’ll retrieve the provider information for a specific resourceType and check whether it’s available in the target region. For this example, we’ll use UAE North for this example.

Sound fun? Let’s dive in!

List Resources for existing Region

Sign into azure using Azure Cli and switch to the subscription containing your region.

Note: We have architected Azure to have one subscription per region, so its fairly easy for us to manage regional resources and cost associated with a specific market. I digress..

So…

az login
az account set --subscription "<name of your regional subscription>"
Enter fullscreen mode Exit fullscreen mode

Getting a flat list by querying all types of resources, and then sort them by unique entry

az resource list --query "[].type" --output tsv | sort -u
Enter fullscreen mode Exit fullscreen mode

The output the following list

Microsoft.AppConfiguration/configurationStores,
Microsoft.Automation/automationAccounts,
Microsoft.Automation/automationAccounts/runbooks,
Microsoft.Compute/virtualMachineScaleSets,
Microsoft.ContainerInstance/containerGroups,
Microsoft.ContainerService/managedClusters
... etc
Enter fullscreen mode Exit fullscreen mode

Listing regional capabilities

From here I concocted the following powershell script to iterate over existing resource types, and check whether they were available in the target region, Add the result to a list, and then output the result.

# List of resource providers and types for an Umbraco Cloud Stamp
$resourceTypes = @(
    "Microsoft.AppConfiguration/configurationStores",
    "Microsoft.Automation/automationAccounts",
    "Microsoft.Automation/automationAccounts/runbooks",
    "Microsoft.Compute/virtualMachineScaleSets",
    "Microsoft.ContainerInstance/containerGroups",
    "Microsoft.ContainerService/managedClusters"
)

# Region to check (Full name of the region)
$region = "UAE North"
$resultList = @()

# Iterate over the resource types and check availability
foreach ($resourceType in $resourceTypes) {
    Write-Host "Checking $resourceType in $region"

    $providerNamespace = $resourceType.Split("/")[0]
    $resourceTypeName = $resourceType.Split("/")[1]

    # Get provider information
    $providerInfo = az provider show --namespace $providerNamespace --query "resourceTypes[?resourceType=='$resourceTypeName']" --output json | ConvertFrom-Json

    if ($providerInfo) {
        $locations = $providerInfo.locations

        $doesExist = $locations -contains $region
        $symbol = if ($doesExist) { "✔" } else { "❌" }

        $resultList += [PSCustomObject]@{
            ResourceType = $resourceType
            DoesExist = $symbol
        }

    }
    else {
        Write-Output "Could not retrieve information for $resourceType"
    }
}

$resultList | Format-Table -AutoSize
Enter fullscreen mode Exit fullscreen mode

The script outputs the following

Name                                               DoesExist
----                                               ---------
Microsoft.AppConfiguration/configurationStores     ✔
Microsoft.Automation/automationAccounts            ✔
Microsoft.Automation/automationAccounts/runbooks   ✔
Microsoft.Compute/virtualMachineScaleSets          ✔
Microsoft.ContainerInstance/containerGroups        ✔
Microsoft.ContainerService/managedClusters         ✔
Microsoft.DocumentDB/databaseAccounts              ✔
Microsoft.Insights/actiongroups                    ❌
...
Enter fullscreen mode Exit fullscreen mode

Conclusion

While we discovered that we were unable to create certain resources in a specific region, it quickly gave us the knowledge needed to provide the business with an assessment of whether we could launch in that region.

On a personal level, I feel like this exercise gave me more insight into the capabilities available through the Azure CLI command. Additionally, I spent roughly 5 hours on the task in total. Next time the business asks if we can launch in a region, we’ll be able to provide an answer even faster.

Top comments (0)