
close
close
In part two of this series, I showed you how to autoscale virtual machines (VMs) using Virtual Machine Scale Sets (VMSS) and Managed Disks behind a load balancer. In part three, I’ll look at how to configure vertical scaling (up and down) as an alternative to the default horizontal scaling (in and out). For more information on VMSS, Managed Disks, and vertical versus horizontal scaling, read part one and two of the series.
advertisment
Azure Autoscale uses horizontal scaling by default. This is the best solution to avoid interruptions in service because it does not require rebooting VMs. But vertical scaling can be achieved with the help of metrics, VMSS alerts, and Azure Automation runbooks. As you have probably guessed, it is more complicated to set up, test, and maintain. Nevertheless, I will show you how to configure a runbook to scale down VMs in the VMSS if CPU utilization drops below five percent. The same method can be used to scale up VMs.
Before you can use a runbook for vertical scaling, you will need an Azure Automation account with a Run as Account. This allows the runbook to authenticate with Azure Resource Manager (ARM) resources.
advertisment
Add an Azure Automation Account (Image Credit: Russell Smith)
The new automation account will appear in the Automation Accounts pane when deployment has completed. You might need to click Refresh to see if the pane is still open.
Microsoft has created four runbooks for vertical scaling VMs in a VMSS. You can add them to your Azure Automation account by downloading them from the gallery.
Import PowerShell Runbooks (Image Credit: Russell Smith)
Add a Webhook (Image Credit: Russell Smith)
Before you can use an imported runbook, you need to publish it. First, decide which runbook you want to use. There are two runbooks that scale down VMs in a VMSS. You can choose to scale down, or scale down and reprovision. The latter choice removes existing VMs and replaces them with new ones. In this article, I will use a runbook that does not reprovision the VMs.
A webhook is a URL that will allow a VMSS alert to send information to the runbook. You want to do this so that an action can be automatically triggered.
advertisment
Add a Webhook (Image Credit: Russell Smith)
The final step is to add an alert to the VMSS. This will raise the alarm when CPU usage rises above five percent. You will need the URL of the webhook that was created above.
Add a VMSS Alert (Image Credit: Russell Smith)
Now all you need to do is wait for an alert to be generated. This alert will trigger the runbook via the webhook. Note that you cannot trigger the runbook manually for testing. It is designed to work only when triggered by an alert. It is also worth noting that not all VMs sizes can be scaled down. For more information on which VMs sizes can be scaled, open the runbook code by clicking View at the top of the runbook’s pane.
View the Runbook Code (Image Credit: Russell Smith)
In this article, I showed you how to configure vertical scaling for VMSS using Azure Automation and a PowerShell runbook.
More from Russell Smith
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Cloud Computing
Use Azure ExpressRoute Private Peering & Azure Virtual WAN to Connect Privately to Microsoft 365
Apr 21, 2022 | Flo Fox
Microsoft to Make Changes to Cloud Licensing Restrictions after Customer Complaints
Apr 18, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group