Vertically scale Windows VMs with Azure Automation

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

  1. Setup Azure Automation to access your Virtual Machines
  2. Import the Azure Automation Vertical Scale runbooks into your subscription
  3. Add a webhook to your runbook
  4. Add an alert to your Virtual Machine

Scale limitations

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. Also constrained Virtual Machine sizes scale up/down is not supported.

You can choose to scale between the following pairs of sizes:


Initial size Scale up size
Basic_A0 Basic_A1
Basic_A1 Basic_A2
Basic_A2 Basic_A3
Basic_A3 Basic_A4
Standard_A0 Standard_A1
Standard_A1 Standard_A2
Standard_A2 Standard_A3
Standard_A3 Standard_A4
Standard_A5 Standard_A6
Standard_A6 Standard_A7
Standard_A8 Standard_A9
Standard_A10 Standard_A11
Standard_A1_v2 Standard_A2_v2
Standard_A2_v2 Standard_A4_v2
Standard_A4_v2 Standard_A8_v2
Standard_A2m_v2 Standard_A4m_v2
Standard_A4m_v2 Standard_A8m_v2


Initial size Scale up size
Standard_B1s Standard_B2s
Standard_B1ms Standard_B2ms
Standard_B2ms Standard_B4ms
Standard_B4ms Standard_B8ms


Initial size Scale up size
Standard_D1 Standard_D2
Standard_D2 Standard_D3
Standard_D3 Standard_D4
Standard_D11 Standard_D12
Standard_D12 Standard_D13
Standard_D13 Standard_D14
Standard_DS1 Standard_DS2
Standard_DS2 Standard_DS3
Standard_DS3 Standard_DS4
Standard_DS11 Standard_DS12
Standard_DS12 Standard_DS13
Standard_DS13 Standard_DS14
Standard_D1_v2 Standard_D2_v2
Standard_D2_v2 Standard_D3_v2
Standard_D3_v2 Standard_D4_v2
Standard_D4_v2 Standard_D5_v2
Standard_D11_v2 Standard_D12_v2
Standard_D12_v2 Standard_D13_v2
Standard_D13_v2 Standard_D14_v2
Standard_DS1_v2 Standard_DS2_v2
Standard_DS2_v2 Standard_DS3_v2
Standard_DS3_v2 Standard_DS4_v2
Standard_DS4_v2 Standard_DS5_v2
Standard_DS11_v2 Standard_DS12_v2
Standard_DS12_v2 Standard_DS13_v2
Standard_DS13_v2 Standard_DS14_v2
Standard_D2_v3 Standard_D4_v3
Standard_D4_v3 Standard_D8_v3
Standard_D8_v3 Standard_D16_v3
Standard_D16_v3 Standard_D32_v3
Standard_D32_v3 Standard_D64_v3
Standard_D2s_v3 Standard_D4s_v3
Standard_D4s_v3 Standard_D8s_v3
Standard_D8s_v3 Standard_D16s_v3
Standard_D16s_v3 Standard_D32s_v3
Standard_D32s_v3 Standard_D64s_v3
Standard_DC2s Standard_DC4s


Initial size Scale up size
Standard_E2_v3 Standard_E4_v3
Standard_E4_v3 Standard_E8_v3
Standard_E8_v3 Standard_E16_v3
Standard_E16_v3 Standard_E20_v3
Standard_E20_v3 Standard_E32_v3
Standard_E32_v3 Standard_E64_v3
Standard_E2s_v3 Standard_E4s_v3
Standard_E4s_v3 Standard_E8s_v3
Standard_E8s_v3 Standard_E16s_v3
Standard_E16s_v3 Standard_E20s_v3
Standard_E20s_v3 Standard_E32s_v3
Standard_E32s_v3 Standard_E64s_v3


Initial size Scale up size
Standard_F1 Standard_F2
Standard_F2 Standard_F4
Standard_F4 Standard_F8
Standard_F8 Standard_F16
Standard_F1s Standard_F2s
Standard_F2s Standard_F4s
Standard_F4s Standard_F8s
Standard_F8s Standard_F16s
Standard_F2s_v2 Standard_F4s_v2
Standard_F4s_v2 Standard_F8s_v2
Standard_F8s_v2 Standard_F16s_v2
Standard_F16s_v2 Standard_F32s_v2
Standard_F32s_v2 Standard_F64s_v2
Standard_F64s_v2 Standard_F7s_v2


Initial size Scale up size
Standard_G1 Standard_G2
Standard_G2 Standard_G3
Standard_G3 Standard_G4
Standard_G4 Standard_G5
Standard_GS1 Standard_GS2
Standard_GS2 Standard_GS3
Standard_GS3 Standard_GS4
Standard_GS4 Standard_GS5


Initial size Scale up size
Standard_H8 Standard_H16
Standard_H8m Standard_H16m


Initial size Scale up size
Standard_L4s Standard_L8s
Standard_L8s Standard_L16s
Standard_L16s Standard_L32s
Standard_L8s_v2 Standard_L16s_v2
Standard_L16s_v2 Standard_L32s_v2
Standard_L32s_v2 Standard_L64s_v2
Standard_L64s_v2 Standard_L80s_v2


Initial size Scale up size
Standard_M8ms Standard_M16ms
Standard_M16ms Standard_M32ms
Standard_M32ms Standard_M64ms
Standard_M64ms Standard_M128ms
Standard_M32ls Standard_M64ls
Standard_M64s Standard_M128s
Standard_M64 Standard_M128
Standard_M64m Standard_M128m


Initial size Scale up size
Standard_NC6 Standard_NC12
Standard_NC12 Standard_NC24
Standard_NC6s_v2 Standard_NC12s_v2
Standard_NC12s_v2 Standard_NC24s_v2
Standard_NC6s_v3 Standard_NC12s_v3
Standard_NC12s_v3 Standard_NC24s_v3
Standard_ND6 Standard_ND12
Standard_ND12 Standard_ND24
Standard_NV6 Standard_NV12
Standard_NV12 Standard_NV24
Standard_NV6s_v2 Standard_NV12s_v2
Standard_NV12s_v2 Standard_NV24s_v2
Standard_NV12s_v3 Standard_NV48s_v3

Setup Azure Automation to access your Virtual Machines

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:

Import the Azure Automation Vertical Scale runbooks into your subscription

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

Import runbooks

Add a webhook to your runbook

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.

Add an alert to your Virtual Machine

  1. Select Virtual Machine settings
  2. Select "Alert rules"
  3. Select "Add alert"
  4. Select a metric to fire the alert on
  5. Select a condition, which when fulfilled will cause the alert to fire
  6. Select a threshold for the condition in Step 5. to be fulfilled
  7. Select a period over which the monitoring service will check for the condition and threshold in Steps 5 & 6
  8. Paste in the webhook you copied from the previous section.

Add Alert to Virtual Machine 1

Add Alert to Virtual Machine 2