Share via


Get all of the Virtual Machines [SPFSDK][VMROLE]

 

Applies To: Windows Azure Pack

When you have reference to a virtual machine role (VM role) instance, the virtual machines hosted by the VM role can be managed. With the VM Role instance, virtual machines can be created, deleted, or changed.

Get all of the virtual machines of a virtual machine role instance

Tip

To learn how to get a virtual machine role instance, see Get a VM Role Instance [SPFSDK][VMROLE].

All virtual machines for a VM role are located at http://server-name:server-port/subscription-id/CloudServices/cloudservice-name/Resources/MicrosoftCompute/VMRoles/vmrole-name/VMs.

Tip

For more information about the placeholders used in the URL, see URL Cheat Sheet for VM Roles [SPFSDK][VMROLE].

Important

Anytime you access a resource within cloud services, you must append the api-version=2013-03 query string. The query string always starts with the ? character after the URL.

Get all of the virtual machines of a virtual machine role instance with HTTP

  1. Use a GET HTTP operation.

  2. Set the URI of the HTTP operation to the format previously described.

  3. Set the x-ms-principal-id header to the email of the tenant associated with the current subscription.

  4. If you want to use json as the response type add the Accept header and set the value to application/json

  5. Set any other standard HTTP headers, such as those related to authentication tokens, and add any authentication certificates that may be required.

  6. Submit the request.

HTTP GET request

GET https://smapiserver:30005/f86b0bc2-6825-4e5b-961b-10d5901f7572/CloudServices/CloudService1/Resources/MicrosoftCompute/VMRoles/VMRole1/VMs?api-version=2013-03 HTTP/1.1
x-ms-principal-id: tenant@contoso.com
Accept: application/json
Host: smapiserver:30005

HTTP GET response

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 306
Content-Type: application/json; odata=minimalmetadata; streaming=true; charset=utf-8
Server: Microsoft-IIS/8.5
X-Content-Type-Options: nosniff
request-id: 33c9dafc-df0d-0000-768d-ca330ddfce01
DataServiceVersion: 3.0;
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
Date: Thu, 14 Nov 2013 20:09:35 GMT

{
    "odata.metadata": "https://spfserver:8090/SC2012R2/VMM/Microsoft.Management.Odata.svc/$metadata#VM",
    "value": [{
        "ComputerName": "LAMP001.mydns1",
        "ConnectToAddresses": [{
            "IPAddress": "10.0.0.2",
            "NetworkName": "Network1",
            "Port": 3389
        }],
        "Id": "73b04c76-ad83-45bf-ba8a-90b07e4029d8",
        "RuntimeState": "Running"
    }]
}

See Also

VM Role Instances [SPFSDK][VMROLE]
Get a VM Role Instance [SPFSDK][VMROLE]
Get a Single Virtual Machine [SPFSDK][VMROLE]
Repair a VM Role [SPFSDK][VMROLE]
Scale a VM Role [SPFSDK][VMROLE]