Unable to setup AutoScale for Virtual Machines from the Azure Management Portal
You can set up AutoScale for your Cloud Services, Virtual Machines, Web Sites from the Azure Management Portal. For Virtual Machines, autoscale can be configured for each availability set. You can setup AutoScale for your availability set only if:
- You have only ‘Standard’ VMs in your Availability Set. Basic VMs cannot participate in AutoScaling.
- Your ‘Standard’ VMS are of same size.
Currently the Portal doesn’t allow you to configure AutoScale for the AvailabilitySet if you have a ‘Basic’ VM in the Cloud Service, even if that ‘Basic’ VM is not present in this AvailbilitySet for which you are configuring AutoScale. This is already identified as a problem, and our teams are working to fix it sooner in the Portal. I’ll update this blog post once this is resolved.
However, you can easily configure AutoScale for the Virtual Machines using the Service Management REST APIs. You can programmatically use the REST APIs, and pass in the necessary parameters, or you could any tool that’s capable of creating a simple HTTP(S) request, attaching a client certificate. To use the REST API, you need to pass in the client certificate that is already uploaded to your Azure Subscription.
Here are the brief steps:
Create a new self-signed Certificate, and upload to the Azure Management Portal
You can follow this article to create a new certificate. Once you execute the makecert command mentioned, the certificate will be created at user’s personal store. You need to then export the certificate as a .cer file, and then upload it to the Azure Management Portal (Settings –> Management Certificates).
Use Fiddler to generate the REST API Request, and pass the right parameters
AutoScale REST API is documented here. To set up AutoScale, we need to use the ‘Update Autoscale settings’ operation. This is a PUT request with the right parameters. URI Parameter to the endpoint would be resourceId=/virtualmachines/<cloudservice>/availabilitySets/<availability-set>. The documentation page has the structure of request body.
Let’s use Fiddler to craft this HTTPS request, with the client certificate.
- Place the exported .cer file under C:\Users\<username>\Documents\Fiddler2 naming it as ‘ClientCertificate.cer’.
- Run Fiddler, and you can stop the capture (File –> Capture Traffic). Else you will see all the outgoing HTTP(S) traffic from this machine on the Fiddler.
- In the right hand side, choose “Composer” tab.
- Use the below settings:
Setting | Value |
Request Verb | PUT |
URL | https://management.core.windows.net/<subscription-ID>/services/monitoring/autoscalesettings?resourceId=/virtualmachines/<cloud-service-name>/availabilitySets/<availabilitySetName> |
Headers | x-ms-version: 2013-10-01 Content-Type: application/json |
Body | {"Profiles":[{"Name":"Day Time","Capacity":{"Minimum":"2","Maximum":"2","Default":"2"},"Rules":[],"Recurrence":{"Frequency":"Week","Schedule":{"TimeZone":"Pacific Standard Time","Days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"Hours":[9],"Minutes":[0]}}},{"Name":"Night Time","Capacity":{"Minimum":"1","Maximum":"1","Default":"1"},"Rules":[],"Recurrence":{"Frequency":"Week","Schedule":{"TimeZone":"Pacific Standard Time","Days":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"Hours":[18],"Minutes":[0]}}}],"Enabled":true} |
Above is an example setting that would scale based on the timings. Day time (9AM to 6PM PST), it scales to 2 instances by default, and in the night time, it reduces the instance size to just 1. You could use the various other parameters documented in this page to alter the request body to choose the right setting.
Tip : You could also do a GET operation to the same endpoint, and get the scale setting. For example, since you are not able to configure it via the portal if you have a Basic VM in your Cloud service, you could create a test Cloud Service, and add standard VMs, and configure the AutoScale from the Portal. Then, do a GET operation to that using Fiddler, or any other tool, and use the JSON output in the PUT operation.
Hope this helps!
Comments
Anonymous
October 16, 2014
This is still an issue. I'm using a VM in "US Central" and all are standard, none are basic. doesn't work using the GUI.Anonymous
October 17, 2014
Hi ChrisL - Can you check the VM sizes? Are they of same sizes?Anonymous
August 25, 2015
hello Rakki, i've seen two VMs in Size (Standard_DS3) running in classic mode (Azure Service Manager). i'm unable to configure autoscale. is autoscale possible with DS-VMs? cheers patrick