Region names/id's in ServiceTags_Public_*.json are different from region names in Get-AzLocation?

GeertvanZoest-0337 0 Reputation points
2023-09-29T12:08:04.6066667+00:00

I want to automate the process of updating firewall inbound ACL's with the frequently changing ip addresses of Azure / Microsoft services. So I regularly need an up-to-date list of the subnets / address prefixes these services use. Most of the time, I get around just fine with Get-AzNetworkServiceTag. But in this case, I need the ip's of Azure DevOps Microsoft-hosted Agents and they are not included in Get-AzNetworkServiceTag as explained in this article. So, I have to use the ServiceTags JSON-file that Microsoft publishes.

Technically, no biggie: just fetching content from a JSON-file instead of a cmdlet's output. If it wasn't for the JSON-file to contain unexpected values.

When using Get-AzLocation to determine the regions in my geography, this is returned:

PS C:\> Get-AzLocation | Where-Object {$_.GeographyGroup -eq 'Europe'} | Select-Object -ExpandProperty 'Location'
northeurope
swedencentral
uksouth
westeurope
francecentral
germanywestcentral
italynorth
norwayeast
polandcentral
switzerlandnorth
francesouth
germanynorth
norwaywest
switzerlandwest
ukwest

But the ServiceTags_Public_20230925.json uses different values. For example:

# Gets latest list of Azure IP ranges from Microsoft
$JsonFileUrl = 'https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_20230925.json'
$JsonFileName = "ServiceTags_Public_20230925.json"

# Download file
$null = Invoke-WebRequest -Uri $JsonFileUrl -OutFile $JsonFileName

# Parse file as JSON-object
$Json = Get-Content -LiteralPath $JsonFileName -Raw | ConvertFrom-Json

# Return unique region names in geography 'Europe'
$Json.values.properties | Where-Object {$_.region -like '*germany*'} | Select-Object -ExpandProperty region -Unique | Where-Object -Property region -like '*germany*' | Select-Object -ExpandProperty region -Unique

# Result:
germanyn
germanywc

So germanywestcentral in Get-AzLocation seems to be germanywc in the JSON-file. But also: germanynorth equals to germanyn. And francecentral = centralfrance and francesouth = southfrance and norwayeast = norwaye, etc.

But ukwest = ukwest and westeurope = westeurope so they are not all useless...

Obviously, I need these values to be identical to do the automation stuff. Does anyone know how to get this right? Am I looking at the wrong place (Get-AzLocation) for proper mapping?

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,201 questions
{count} votes