Vertical scaling is the process of increasing or decreasing the resources of a machine in response to the workload. In Azure this can be accomplished by changing the size of the Virtual Machine. This can help in the following scenarios
- If the Virtual Machine is not being used frequently, you can resize it down to a smaller size to reduce your monthly costs
- If the Virtual Machine is seeing a peak load, it can be resized to a larger size to increase its capacity
The outline for the steps to accomplish this is as below
- Setup Azure Automation to access your Virtual Machines
- Import the Azure Automation Vertical Scale runbooks into your subscription
- Add a webhook to your runbook
- Add an alert to your Virtual Machine
[AZURE.NOTE] Because of the size of the first Virtual Machine, the sizes it can be scaled to, may be limited due to the availability of the other sizes in the cluster current Virtual Machine is deployed in. In the published automation runbooks used in this article we take care of this case and only scale within the below VM size pairs. This means that a Standard_D1v2 Virtual Machine will not suddenly be scaled up to Standard_G5 or scaled down to Basic_A0.
| VM sizes scaling pair | | |---|---| | Basic_A0 | Basic_A4 | | Standard_A0 | Standard_A4 | | Standard_A5 | Standard_A7 | | Standard_A8 | Standard_A9 | | Standard_A10 | Standard_A11 | | Standard_D1 | Standard_D4 | | Standard_D11 | Standard_D14 | | Standard_DS1 | Standard_DS4 | | Standard_DS11 | Standard_DS14 | | Standard_D1v2 | Standard_D5v2 | | Standard_D11v2 | Standard_D14v2 | | Standard_G1 | Standard_G5 | | Standard_GS1 | Standard_GS5 |
The first thing you need to do is create an Azure Automation account that will host the runbooks used to scale a Virtual Machine. Recently the Automation service introduced the "Run As account" feature which makes setting up the Service Principal for automatically running the runbooks on the user's behalf very easy. You can read more about this in the article below:
The runbooks that are needed for Vertically Scaling your Virtual Machine are already published in the Azure Automation Runbook Gallery. You will need to import them into your subscription. You can learn how to import runbooks by reading the following article.
The runbooks that need to be imported are shown in the image below
Once you've imported the runbooks you'll need to add a webhook to the runbook so it can be triggered by an alert from a Virtual Machine. The details of creating a webhook for your Runbook can be read here
Make sure you copy the webhook before closing the webhook dialog as you will need this in the next section.
- Select Virtual Machine settings
- Select "Alert rules"
- Select "Add alert"
- Select a metric to fire the alert on
- Select a condition, which when fulfilled will cause the alert to fire
- Select a threshold for the condition in Step 5. to be fulfilled
- Select a period over which the monitoring service will check for the condition and threshold in Steps 5 & 6
- Paste in the webhook you copied from the previous section.