Share via


Scale a VM Role [SPFSDK][VMROLE]

 

Applies To: Windows Azure Pack

Virtual machine roles (VM role) represent one or more virtual machines dedicated to a specific operation, such as a web server or web worker. At times, you may need to adjust how many virtual machines of a particular VM role are instantiated. The VM role provides a scale operation that allows you to adjust the virtual machine instances. The amount of virtual machine instances can never go below the minimum and above the maximum allowed virtual machine instances as configured by the VM role.

Scale a virtual machine role

The scale operation is available at the VM role instance URI: http://server-name:server-port/subscription-id/CloudServices/cloudservice-name/Resources/MicrosoftCompute/VMRoles/vmrole-name/Scale?api-version=2013-03. The HTTP body of the request should be a JSON object with a single property named InstanceCount. The value of this property should be the absolute count of virtual machine instances.

Submit an HTTP POST request to the server URI referenced above.

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.

Once the scale operation has been initiated, the ProvisioningState property of the VM role will change to Provisioning. Keep refreshing the VM role instance from the server and wait for the ProvisioningState property to change to Provisioned or Failed. If the value is Failed, see Inspect a VM Role for Provisioning Errors [SPFSDK][VMROLE] for more information.

Scale the virtual machines instances of a VM 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. Create the HTTP request body, which should be a JSON object.

  7. Create a property on the JSON object named InstanceCount and set the value to the absolute count of virtual machine instances.

  8. Submit the request.

HTTP GET request

POST https://smapi-server:30005/f86b0bc2-6825-4e5b-961b-10d5901f7572/CloudServices/testquickvm/Resources/MicrosoftCompute/VMRoles/testquickvm/Scale?api-version=2013-03 HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6InhUOE1XSFJ0aDVGVmNNSS1CTWlqWTc1Q1dhOCJ9.eyJpc3MiOiJodHRwOi8vYXp1cmVzZXJ2aWNlcy9BdXRoU2l0ZSIsImF1ZCI6Imh0dHA6Ly9henVyZXNlcnZpY2VzL1RlbmFudFNpdGUiLCJuYmYiOjEzODUwODA4MzksImV4cCI6MTM4NTEwOTYzOSwidXBuIjoiZnJlZEBmcmVkLmNvbSIsImF1dGhfdGltZSI6IjIwMTMtMTEtMjJUMDA6NDA6MzkuNjk2WiIsImF1dGhtZXRob2QiOiJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvYXV0aGVudGljYXRpb25tZXRob2QvcGFzc3dvcmQifQ.NlxoyYptJqoPRCQnprSvwdPTLbl3wgUjCKSKaMgbwIlKJ_8Gs2Z9Uf8Euj557hWPI5Gj7o5wjkfqXoun1RjUoyXd3DUyYSQ2WCbqBWEGNQt0dW9gz_v7TpzliqXqDkHKQJrOGkexSb0t0dg4ncmoD3by3ambirnYmfsPAwahiqVmIi5J3SyA8gpeMnwEmCJZVeta4NAqfWvJNaW7JEb2rZYyDsUdCVeQOzO0Dr57IdeyMecHKTeE53QkQG-g86bVx_OmXvNMR_reoraVGnfNz5LgH4tywkc70RtdW3zQDCA-aOLvt87Et35TvuDRiHg4qlDwcoQORQ0gtH0htIaF8w
x-ms-principal-id: user@contoso.com
Accept: application/json
Content-Type: application/json
Host: smapi-server:30005
Content-Length: 22
Expect: 100-continue

{ "InstanceCount": 2 }

HTTP GET response

HTTP/1.1 204 No Content
Cache-Control: no-cache
Content-Length: 0
Server: Microsoft-IIS/8.5
x-ms-request-id: eaaf0fea-c921-488b-a61e-b6d91d2e99e2
X-Content-Type-Options: nosniff
request-id: 33c9dafc-df0d-0000-7df9-ca330ddfce01
DataServiceVersion: 1.0;
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
Date: Fri, 22 Nov 2013 00:40:45 GMT

See Also

VM Role Instances [SPFSDK][VMROLE]
Get a VM Role Instance [SPFSDK][VMROLE]
Get all of the Virtual Machines [SPFSDK][VMROLE]
Get a Single Virtual Machine [SPFSDK][VMROLE]
Repair a VM Role [SPFSDK][VMROLE]