Azure – List Azure Virtual Machines via REST API


I am currently attempting to get a list of all of the Virtual Machines that I have running under a Windows Azure subscription programmatically. For this, I am attempting to use the Azure REST API (, and not use the power-shell cmdlets.

Using the cmdlets I can run 'Get-AzureVM' and get a listing of all of the VM's with ServiceName, Name, and Status without any modifications. The problem is that I cannot find anywhere in the documentation of how to list out the VMs via the API.

I have looked through the various Azure REST API's but have not been able to find anything. The documentation for VM REST API does not show or provide a list function.

Am I missing the fundamentals somewhere?

// Create the request.
            requestUri = new Uri(""
                                 + subscriptionId 
                                 + "/services/" 
                                 + operation);

This is what I am using for the base of the request. I can get a list of hosted services but not the Virtual Machines.

Best Solution

You would need to get a list all the Cloud Services (Hosted Services), and then the deployment properties for each. Look for the deployment in the Production environment/slot. Then check for a role type of "PersistentVMRole".

VMs are really just a type of Cloud Service, along with Web and Worker roles. The Windows Azure management portal and PowerShell cmdlets abstracts this away to make things a little easier to understand and view.

Related Question