Created
September 18, 2017 19:45
-
-
Save siennathesane/1d74ef584675c9820f3268de0f74f00a to your computer and use it in GitHub Desktop.
Get a list of all Azure Regions for your Subscription.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from azure.common.credentials import ServicePrincipalCredentials | |
| from azure.mgmt.resource.subscriptions import SubscriptionClient | |
| from json import dumps | |
| import os | |
| def get_azure_regions(): | |
| client = SubscriptionClient(credential_loader()) | |
| locations = client.subscriptions.list_locations(os.getenv("AZURE_SUBSCRIPTION_ID")) | |
| regions = {} | |
| for x in locations: | |
| regions[x.display_name] = x.name | |
| print(dumps(regions)) | |
| def credential_loader(): | |
| return ServicePrincipalCredentials( | |
| client_id=os.getenv("AZURE_CLIENT_ID"), | |
| secret=os.getenv("AZURE_CLIENT_SECRET"), | |
| tenant=os.getenv("AZURE_TENANT_ID") | |
| ) | |
| def main(): | |
| get_azure_regions() | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of Sept 18th, 2017:
{ "East US 2": "eastus2", "Central India": "centralindia", "Central US": "centralus", "West US": "westus", "UK South": "uksouth", "South India": "southindia", "Korea Central": "koreacentral", "Korea South": "koreasouth", "South Central US": "southcentralus", "East US": "eastus", "Brazil South": "brazilsouth", "Canada Central": "canadacentral", "North Central US": "northcentralus", "West Europe": "westeurope", "Canada East": "canadaeast", "West India": "westindia", "Japan West": "japanwest", "East Asia": "eastasia", "Southeast Asia": "southeastasia", "Australia Southeast": "australiasoutheast", "Australia East": "australiaeast", "West US 2": "westus2", "North Europe": "northeurope", "UK West": "ukwest", "Japan East": "japaneast", "West Central US": "westcentralus" }