Hi everyone please help me . I want to get available location based on my existing virtual machine configuration using azure rest api.
1 Answers
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.

- 4,923
- 2
- 13
- 30
-
Thanks for your response but I need to move my virtual machine from current location to another location so firstly I have to check destination location have availability or not. – Unknow Feb 14 '21 at 08:16
-
@Unknow Ohk, that wasn't clear from the question. Updated my response with the requested details. Please check. – Bhargavi Annadevara Feb 14 '21 at 17:02
-
@Unknow Do the provided inputs help? – Bhargavi Annadevara May 01 '21 at 17:46