Your app and its database are both pinned to zone 1, yet latency looks cross-zone. Or an incident notice names a physical zone and you need to know which resources are in it. Zone numbers in Azure are logical and mapped per subscription. Use these commands to translate them.
The rules
- Logical zone numbers map to physical zones per subscription and per region. Two subscriptions can have different orders.
- The mapping is set when the subscription is created.
- If you pin by number across subscriptions, two "zone 1" resources may be in different buildings, and "zone 1 plus zone 2" may be the same one.
- Zone-redundant services spread across zones themselves. The mapping matters for zonal (pinned) resources.
| Situation | What goes wrong | What to do |
|---|---|---|
| App and database in different subscriptions | Unplanned cross-zone round trips | Pin by physical zone |
| Active and standby in different subscriptions | Both in one physical zone, so no redundancy | Compare mappings |
| Shared capacity reservation | Consumer's zone number points elsewhere | Translate the number for the consumer |
| NVA zonal pair in a hub, spokes in other subscriptions | Asymmetric latency | Translate per spoke |
| DR plan says "fail out of zone 2" | Different teams evacuate different zones | Write physical names in plans |
Show the mapping for one subscription
az account list-locations \
--query "[?name=='westeurope'].availabilityZoneMappings[].{logical:logicalZone, physical:physicalZone}" \
-o table
Physical names look like westeurope-az1. Regions without zones return nothing.
Show it for every subscription you can see
REGION=westeurope
printf "subscription\tlogical\tphysical\n"
for S in $(az account list --query "[?state=='Enabled'].id" -o tsv | tr -d '\r'); do
az rest --method get \
--url "https://management.azure.com/subscriptions/$S/locations?api-version=2022-12-01" \
--query "value[?name=='$REGION'].availabilityZoneMappings[].[logicalZone,physicalZone]" \
-o tsv | tr -d '\r' | sed "s/^/$S\t/"
done
The same in PowerShell, ready for export:
$region = 'westeurope'
Get-AzSubscription | Where-Object State -eq 'Enabled' | ForEach-Object {
$sub = $_
$r = Invoke-AzRestMethod -Method GET -Path "/subscriptions/$($sub.Id)/locations?api-version=2022-12-01"
$loc = ($r.Content | ConvertFrom-Json).value | Where-Object name -eq $region
foreach ($m in $loc.availabilityZoneMappings) {
[pscustomobject]@{ Subscription = $sub.Name; Logical = $m.logicalZone; Physical = $m.physicalZone }
}
} | Export-Csv .\zone-map.csv -NoTypeInformation -Encoding utf8
Store the CSV with your platform code. It is the lookup table for the rest of this page.
Compare with a subscription directly
The Check Zone Peers API returns peer zone numbers from your subscription's point of view. It needs a feature registration, unlike the locations call:
az feature register --namespace Microsoft.Resources --name AvailabilityZonePeering
az feature show --namespace Microsoft.Resources --name AvailabilityZonePeering \
--query properties.state -o tsv
az provider register -n Microsoft.Resources
az rest --method post \
--url "https://management.azure.com/subscriptions/$SUB_A/providers/Microsoft.Resources/checkZonePeers/?api-version=2022-12-01" \
--body "{\"location\":\"westeurope\",\"subscriptionIds\":[\"subscriptions/$SUB_B\"]}"
Use this when a partner gives you only a subscription ID. For your own subscriptions, the locations call is simpler.
From inside a VM
curl -s -H "Metadata:true" --noproxy "*" \
"http://169.254.169.254/metadata/instance/compute?api-version=2023-11-15" \
| jq '{name, location, zone, physicalZone, subscriptionId}'
zone is the logical number and physicalZone the physical one. Use an API version that returns the second field; older versions omit it. Publishing physicalZone as a label on your metrics makes zone incidents visible on a dashboard.
On AKS nodes, the zone label contains the logical number for the cluster's subscription:
kubectl get nodes -L topology.kubernetes.io/zone
westeurope-1 in that label is not the physical westeurope-az1. The similar format causes many wrong conclusions.
Find everything in a physical zone
Translate the physical zone into a logical number for each subscription, then query:
az graph query --first 1000 -q "
resources
| where location =~ 'westeurope' and isnotempty(zones)
| mv-expand zone = zones to typeof(string)
| where (subscriptionId == '<sub-a>' and zone == '1')
or (subscriptionId == '<sub-b>' and zone == '3')
| summarize resources = count() by type, subscriptionId, zone
| order by resources desc" -o table
A resource with several entries in zones is spread or zone-redundant. A single entry means pinned:
resources
| where location =~ "westeurope"
| where type in~ ("microsoft.compute/virtualmachines", "microsoft.compute/disks",
"microsoft.network/publicipaddresses", "microsoft.network/natgateways")
| extend placement = case(
isnull(zones) or array_length(zones) == 0, "no zone",
array_length(zones) == 1, strcat("zonal-", tostring(zones[0])),
"multi-zone")
| summarize count() by type, placement, subscriptionId
Warning
Not every service puts placement in the top-level
zonesproperty. Databases, App Service plans, gateways and node pools often use their own properties. Treat "no zone" as "check the service", not as proof.
Find VMs whose zonal NAT gateway or load balancer frontend is elsewhere by joining on your own inventory. A VM that survives a zone loss but whose only NAT gateway was in that zone has still lost its egress.
Check SKU restrictions by zone
Restrictions are reported in logical zones for the subscription you ask from:
az vm list-skus -l westeurope --zone --size Standard_D8s_v5 --all \
--query "[].{name:name, zones:locationInfo[0].zones, restricted:restrictions[].restrictionInfo.zones, reason:restrictions[].reasonCode}" \
-o json
| Result | Meaning |
|---|---|
Zone in zones, no restriction | Offered to this subscription |
Zone in restricted with NotAvailableForSubscription | Request access, or use another zone or size |
| Offered, but deployment fails with an allocation error | No capacity at that moment; not a restriction |
Do not copy a restricted zone list between subscriptions. Compare physical zones instead.
Measure the latency
Azure's documented aim is under about 2 ms round trip between zones on the network. That is a target, and what your application sees depends on protocol and hops. Measure TCP, not ICMP:
# on the target VM
sockperf sr --tcp -p 12345
# on the client VM: same physical zone first, then cross-zone
sockperf ping-pong -i <target-ip> --tcp -p 12345 -t 60 --full-rtt
Then multiply by round trips per transaction:
| Round trips per request | Extra at 1 ms RTT difference |
|---|---|
| 1 | 1 ms |
| 20 (ORM with N+1 queries) | 20 ms |
| 200 (chatty batch) | 200 ms |
Reducing round trips usually pays back more than zone pinning. Pin by physical zone only if chatty behaviour cannot be fixed and the platform supports it, and keep a complete replica stack in another zone.
Caution
Pinning app and database together improves latency but puts them in one failure domain. Database failover to another zone also moves the latency. Load-test with the database in the remote zone before you depend on the faster number.
Change the zone of something already deployed
You cannot edit a subscription's mapping, and most zonal resources cannot change zone with a property update. Typical routes:
- VMs: snapshot or restore the disks into the target zone and recreate, or use a supported move process. Plan downtime.
- Managed disks: a zonal LRS disk attaches only to a VM in the same zone. Snapshot it and create the new disk with
--zone. - Databases with a standby: move the standby to the right zone first, then fail over.
az snapshot create -g rg-app -n data1-snap --source data1 --incremental true
az disk create -g rg-app -n data1-z3 --source data1-snap --zone 3 --sku Premium_LRS
Warning
Stop writes before the snapshot. Anything written afterwards is not on the new disk.
Prevent it next time
- Take a physical zone as input in templates, and look up the logical number from the saved map at deployment time.
- Check the map in the subscription vending pipeline and publish it for each new subscription.
- Use physical names in runbooks, DR plans and incident channels.
- Prefer zone-redundant options where available, so mapping does not matter.
- Re-run the map when a region gains zones. Existing mappings are kept, and later subscriptions may have a different order.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get