Azure PowerShell – List Data Center Locations

Occasionally I will come across the need to use PowerShell for my day to day activities. One such need came up this week when I was preparing to do training with a customer. Part of that meant creating 6 data science VMs. So we updated the software on a VM and went to clone it, ran into some issues and then decided to break out the PowerShell to fix the issue.

For those who use PowerShell to do anything in Azure you will know that you will often need to supply the location parameter. In the portal that’s not a problem, you just select from the drop down menu. However, in PowerShell you have to know exactly what the name of the data center is and how it is formatted. Is it East US 2, EastUS2, East US2, or something else. And then you have to remember that for all the data centers. And there are a bunch of them; we have 50 regions and counting. Thankfully there is a PowerShell cmdlet that will assist with this!

Let’s fire up Azure PowerShell and take a look.

Of course we will want to login with Connect-AzureRmAccount to get started. Then it is a simple cmdlet with no parameters necessary: Get-AzureRmLocation. You can cleanup the output by adding Format-Table.

Get-AzureRmLocation |Format-Table

Take a look at the Providers property in the output.This lists the resources available in the region. This is useful for finding regions that support Azure SQL, for instance.

Get-AzureRmLocation | Where-Object Providers -like "*sql*" | Format-Table

Should you decide that you just want to view all the services in a particular region, it’s not too much extra work.

$providers = Get-AzureRmLocation | Where-Object {$_.Location -eq "eastus2"} | select Providers
$providers.Providers

There you have it. A handy little PowerShell cmdlet that will help you figure out what to put in the location parameter for other cmdlets like creating a Virtual Machine or creating a new Azure SQL Database.

Next week we’ll take a look at finding the virtual machine sizes that are available in each data center and the associated parameter values.

**Update** The next blog has been release: Azure PowerShell – List Virtual Machine Sizes

Bradley Schacht

Bradley Schacht is a Cloud Solution Architect on the state and local government team with Microsoft based in Jacksonville, FL. He has co-authored 3 SQL Server books including "SQL Server 2014 Professional Administration". As a former consultant and trainer, he uses his experience on many parts of the Microsoft BI and data platform to help customers deliver the best possible solutions. Bradley frequently presents at community events around the country. He is a contributor to sites such as SQLServerCentral.com and an active member of the Jacksonville SQL Server User Group (JSSUG).

You may also like...

1 Response

  1. May 29, 2018

    […] are and enter into the text box where it’s a free form value. Last week I wrote about using PowerShell to get a list of all the data center values. So when you have to chose a location you know if the parameter value should be EastUS or East US. […]

Leave a Reply