Reputation: 1881
I would like to list all Azure locations via some API (I need to generate some config files for every region, and use the exact naming that Azure does to avoid typos). I found this question, but it only lists regions a particular subscription is authorized to use.
I want to list all regions that exist whether my subscription has access or not.
Upvotes: 52
Views: 52496
Reputation: 743
# List supported regions for the current subscription
az account list-locations --output table
# Regions
az account list-locations \
--query '[?type==`Region`].{"Geography group":metadata.geographyGroup, Name:name, "Display Name":displayName, Geography:metadata.geography, Location:metadata.physicalLocation, Category:metadata.regionCategory, Type:type, "Region type":metadata.regionType}' \
--output table
# Physical regions
az account list-locations \
--query 'sort_by([?metadata.regionType==`Physical`].{"Geography group":metadata.geographyGroup, Name:name, "Display Name":displayName, Geography:metadata.geography, Location:metadata.physicalLocation, Category:metadata.regionCategory, Type:type, "Region type":metadata.regionType}, &"Geography group")' \
--output table
# Europe regions
az account list-locations \
--query '[?metadata.geographyGroup==`Europe`].{"Geography group":metadata.geographyGroup, Name:name, "Display Name":displayName, Geography:metadata.geography, Location:metadata.physicalLocation, Category:metadata.regionCategory, Type:type, "Region type":metadata.regionType}' \
--output table
Geography group Name Display Name Geography Location Category Type Region type
----------------- ------------------ -------------------- -------------- ----------- ----------- ------ -------------
Europe northeurope North Europe Europe Ireland Recommended Region Physical
Europe swedencentral Sweden Central Sweden Gävle Recommended Region Physical
Europe uksouth UK South United Kingdom London Recommended Region Physical
Europe westeurope West Europe Europe Netherlands Recommended Region Physical
Europe francecentral France Central France Paris Recommended Region Physical
Europe germanywestcentral Germany West Central Germany Frankfurt Recommended Region Physical
Europe italynorth Italy North Italy Milan Recommended Region Physical
Europe norwayeast Norway East Norway Norway Recommended Region Physical
Europe polandcentral Poland Central Poland Warsaw Recommended Region Physical
Europe spaincentral Spain Central Spain Madrid Recommended Region Physical
Europe switzerlandnorth Switzerland North Switzerland Zurich Recommended Region Physical
Europe francesouth France South France Marseille Other Region Physical
Europe germanynorth Germany North Germany Berlin Other Region Physical
Europe norwaywest Norway West Norway Norway Other Region Physical
Europe switzerlandwest Switzerland West Switzerland Geneva Other Region Physical
Europe ukwest UK West United Kingdom Cardiff Other Region Physical
az account list-locations
Upvotes: 0
Reputation: 911
I actually decided to make a website that has a JSON file updated daily for this: http://azureregions.com/ or for just the json list https://azureregions.com/locations.json
Upvotes: 0
Reputation: 985
I have been looking into a way to get the Azure regions without needing to authenticate to Azure and came across this thread. Similar to @girip11's response, I have been building on the public Azure documentation. This is the python script to get the data:
import requests
import pandas as pd
from re import search
def list_azure_regions():
url = 'https://azure.microsoft.com/en-us/explore/global-infrastructure/geographies/'
html = requests.get(url).content
df_list = pd.read_html(html)
regions_list = []
locations_list = []
for df in df_list:
for dc in list(df):
if search('Regions', dc):
pass
else:
if search('Coming soon', dc):
state = 'planned'
else:
state = 'active'
location = df[dc][0]
region = dc.removesuffix(' Start free')
region = region.removesuffix(' Get started')
region = region.removesuffix(' Coming soon')
if region in regions_list:
pass
else:
regions_list.append(region)
locations_list.append(
dict({
'display_name': region,
'name': region.replace(' ','').lower(),
'location': location,
'state': state
})
)
return locations_list
azure_regions = list_azure_regions()
print(azure_regions)
The script returns a response of type <class 'list'>
but could be converted to something more readable if required. I.E. when running on Windows:
> python .\get-azure-regions.py | ConvertFrom-Json
display_name name location state
------------ ---- -------- -----
East Asia eastasia Hong Kong active
Southeast Asia southeastasia Singapore active
Australia Central australiacentral Canberra active
Australia East australiaeast New South Wales active
Australia Southeast australiasoutheast Victoria active
China East chinaeast Shanghai active
China East 2 chinaeast2 Shanghai active
China North chinanorth Beijing active
China North 2 chinanorth2 Beijing active
China North 3 chinanorth3 Hebei active
Central India centralindia Pune active
India South Central indiasouthcentral Hyderabad active
South India southindia Chennai active
Indonesia Central indonesiacentral Jakarta planned
Japan East japaneast Tokyo, Saitama active
Japan West japanwest Osaka active
Korea Central koreacentral Seoul active
Malaysia West malaysiawest Kuala Lumpur planned
New Zealand North newzealandnorth Auckland planned
Taiwan North taiwannorth Taipei planned
Austria East austriaeast Vienna planned
Belgium Central belgiumcentral Brussels active
...
Upvotes: 1
Reputation: 11
You can use the following REST API: https://management.azure.com/subscriptions/**YOUR_SUBSCRIPTION_ID**/providers?api -version=2020-10-01
SEE:
But, like the PowerShell and the AZ command line, this only shows data center regions available to the specified subscription.
Upvotes: -1
Reputation: 52093
az account list-locations -o table
will give you a table like:
DisplayName Name RegionalDisplayName
------------------------ ------------------- -------------------------------------
East US eastus (US) East US
East US 2 eastus2 (US) East US 2
South Central US southcentralus (US) South Central US
West US 2 westus2 (US) West US 2
Australia East australiaeast (Asia Pacific) Australia East
Southeast Asia southeastasia (Asia Pacific) Southeast Asia
North Europe northeurope (Europe) North Europe
UK South uksouth (Europe) UK South
West Europe westeurope (Europe) West Europe
Central US centralus (US) Central US
North Central US northcentralus (US) North Central US
West US westus (US) West US
South Africa North southafricanorth (Africa) South Africa North
Central India centralindia (Asia Pacific) Central India
East Asia eastasia (Asia Pacific) East Asia
Japan East japaneast (Asia Pacific) Japan East
JIO India West jioindiawest (Asia Pacific) JIO India West
Korea Central koreacentral (Asia Pacific) Korea Central
Canada Central canadacentral (Canada) Canada Central
France Central francecentral (Europe) France Central
Germany West Central germanywestcentral (Europe) Germany West Central
Norway East norwayeast (Europe) Norway East
Switzerland North switzerlandnorth (Europe) Switzerland North
UAE North uaenorth (Middle East) UAE North
Brazil South brazilsouth (South America) Brazil South
Central US (Stage) centralusstage (US) Central US (Stage)
East US (Stage) eastusstage (US) East US (Stage)
East US 2 (Stage) eastus2stage (US) East US 2 (Stage)
North Central US (Stage) northcentralusstage (US) North Central US (Stage)
South Central US (Stage) southcentralusstage (US) South Central US (Stage)
West US (Stage) westusstage (US) West US (Stage)
West US 2 (Stage) westus2stage (US) West US 2 (Stage)
Asia asia Asia
Asia Pacific asiapacific Asia Pacific
Australia australia Australia
Brazil brazil Brazil
Canada canada Canada
Europe europe Europe
Global global Global
India india India
Japan japan Japan
United Kingdom uk United Kingdom
United States unitedstates United States
East Asia (Stage) eastasiastage (Asia Pacific) East Asia (Stage)
Southeast Asia (Stage) southeastasiastage (Asia Pacific) Southeast Asia (Stage)
Central US EUAP centraluseuap (US) Central US EUAP
East US 2 EUAP eastus2euap (US) East US 2 EUAP
West Central US westcentralus (US) West Central US
West US 3 westus3 (US) West US 3
South Africa West southafricawest (Africa) South Africa West
Australia Central australiacentral (Asia Pacific) Australia Central
Australia Central 2 australiacentral2 (Asia Pacific) Australia Central 2
Australia Southeast australiasoutheast (Asia Pacific) Australia Southeast
Japan West japanwest (Asia Pacific) Japan West
Korea South koreasouth (Asia Pacific) Korea South
South India southindia (Asia Pacific) South India
West India westindia (Asia Pacific) West India
Canada East canadaeast (Canada) Canada East
France South francesouth (Europe) France South
Germany North germanynorth (Europe) Germany North
Norway West norwaywest (Europe) Norway West
Switzerland West switzerlandwest (Europe) Switzerland West
UK West ukwest (Europe) UK West
UAE Central uaecentral (Middle East) UAE Central
Brazil Southeast brazilsoutheast (South America) Brazil Southeast
Upvotes: 140
Reputation: 8737
Get-AzureRMLocation
will give you the list of locations for your account/tenant/subscription that you run it against.
From the answer below, this works perfectly with the newer version of Azure PS!
Get-AzLocation | select DisplayName, Location | Format-Table
Upvotes: 19
Reputation: 951
This is an old question and already have an accepted answer. But given there have been few changes in Azure Modules hence adding the latest command here.
I do not think the API for location still exists. But with latest version of Powershell Az module you can fetch the locations
Get-AzLocation | select DisplayName, Location | Format-Table
This gives you some freedom to select the property you need and format the output in tabular format. The AZ CLI command still remains the same as above.
Upvotes: 5
Reputation: 169
A possible solution using powershell script would be to parse the response from the URL: https://azure.microsoft.com/en-us/regions/. Using this, you could get the information about newly announced regions.
If you do not mind using Java or C#, then the below solutions are handy as well.
For region list in java, the dependency in maven is azure-mgmt-resources located at https://github.com/Azure/azure-libraries-for-java/tree/master/azure-mgmt-resources. Documentation: https://azure.github.io/azure-sdk-for-java/com/microsoft/azure/management/resources/fluentcore/arm/Region.html
In case you are using c#, the dependency in nuget is Microsoft.Azure.Management.ResourceManager.Fluent. And for reference, the Source Code URL: https://github.com/Azure/azure-libraries-for-net/blob/master/src/ResourceManagement/ResourceManager/Region.cs
Upvotes: 2