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.
x-ms-version: 2013-10-01 Content-Type: application/json
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!