-1

Hi everyone please help me . I want to get available location based on my existing virtual machine configuration using azure rest api.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30
Unknow
  • 7
  • 2

1 Answers1

1

You can get the location where your VM exists from the Virtual Machines - Get API.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2020-12-01

Sample response:

{
  "name": "MyVM",
  "id": "/subscriptions/***/resourceGroups/***/providers/Microsoft.Compute/virtualMachines/MyVM",
  "type": "Microsoft.Compute/virtualMachines",
  "location": "centralus",
  "tags": {
    ...
  },
  "properties": {
    ...
  },
...
}

Web: This page lists the availability of Azure Virtual Machines by region: Products available by region

REST API: The collection of locations where a certain resource type can be created can be fetched from the Providers - List API from ProviderResourceType property in the response.

PowerShell: An easier alternative is to use the following command to get the supported locations for Azure VMs:

((Get-AzResourceProvider -ProviderNamespace Microsoft.Compute).ResourceTypes | Where-Object ResourceTypeName -eq virtualMachines).Locations

Note that some services or VM features are only available in certain regions, such as specific VM sizes. To determine which SKUs are available in a region/zone, use the Get-AzComputeResourceSku cmdlet (or Resource Skus - List REST API). Filter the results by location.

Get-AzComputeResourceSku | where {$_.ResourceType.Contains("virtualMachines")}

Another great option you may want to explore to move Azure resources between Azure regions is the Azure Resource Mover service. Resource Mover provides a simple and consistent experience with reduced move time and complexity. Checkout this tutorial to move Azure VMs across regions.

Bhargavi Annadevara
  • 4,923
  • 2
  • 13
  • 30