DEV Community

Wilfried Woivré
Wilfried Woivré

Posted on • Originally published at woivre.com on

Azure - Use regional endpoint for ARM REST API calls

Recently I opened different support cases to Microsoft for an unusual behavior on Azure.

When I created a new resource in West Europe, it was available on the Azure portal, but from my Automation Account in North Europe I could not see it.

In other words, when I did a Get-AzStorageAccount -ResourceGroup $resourceGroupName from my workstation I could see my new storage, but from my Automation account I could not.

In order to diagnose the problem there is a very simple way, you just have to do in powershell the following commands:

$token = Get-AzAccessToken
$authHeader = @{
    'Content-Type'='application/json'
    'Authorization'='Bearer ' + $token.Token
}

$locations = @("westeurope", "northeurope")

foreach ($location in $locations) {
    Write-Host "Location : $location" -ForegroundColor Cyan
    $restUrl = "https://$location.management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/resources?api-version=2022-01-01"; 
    (Invoke-WebRequest -Uri $restUrl -Method GET -Headers $authHeader).Headers
}

Enter fullscreen mode Exit fullscreen mode

And you will see through which region your calls go through via the x-ms-routing-request-id header which contains the WESTEUROPE value corresponding to the region

Very useful when there is a synchronization problem on Azure side, and the support can force a sync if you don’t want to wait for it to happen

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay