If you are interested in shutting down Azure VMs on a schedule, learn more here. If shutting down a VM during non-busy hours is impractical, consider scaling it down in power.
In this tutorial, we are going to learn how to do scaling/resizing of Azure (up or down) cloud-based Microsoft Azure Virtual Machines on a schedule. The process takes about 1-2 minutes and is easily replicable to any and all VMs in your Azure subscription in just a few minutes more. It works for Windows and Linux VMs and does not rely on somewhat complex and hard to maintain PowerShell scripts or Azure Automation runbooks. Also, if any errors occur during execution of scale commands, you will get an immediate notification.
Scheduling scaling of your VMs allows you to save money on Azure costs. A scaled-down VM incurs lowered Azure charges This can be beneficial for DEV/QA and other non-production environments, CI/build servers, or for production environments where optimal access to VMs is required only during specific times. Consider an example: a CI/SourceCode build server must be very powerful during the day time to assist the development team with continuous builds after frequent check ins. However, during the night hours, it can be scaled down in size to support occasional check ins from a few developers who are working late.
You will need a Netreo account. If you have not yet registered, do so here. Netreo is a sophisticated monitoring and automation software-as-a-service for Azure. By using Netreo, you’ll have access to a ton of useful performance metrics, logs, alerts, integrations, and other automation features. While during the 2-week trial period everything in Netreo is free, after the trial expires, automated VM Resizing will only be available for users of Netreo’s Ultimate plan. Many companies easily justify the relatively inexpensive cost of Netreo by configuring it to power-down or scale-down their unused VMs.
Technical considerations to note: when a VM is resized, it is rebooted. VM resizing is not recommended for stand-alone servers that need to remain up 24/7. It is recommended that such servers be a part of multi-server Availability Sets, so that reboots in one server do not cause the whole availability set to be down.
Resizing a VM does not cause any change to OS or underlying data. It is simply rebooted with more or less power allocated to it by Azure platform.
Ensure that your Azure Virtual Machines have been added to Netreo account. Simplest way to do so is to run through the Netreo Setup Wizard. It takes a few minutes, and it is very intuitive and straightforward.
After Wizard completes, edit the monitoring definition of a particular Azure VM and on the Actions tab and define two actions; one to resize UP and one to resize DOWN a VM at specific times. In detail:
Configuring other VMs to scale on the same schedule is a fairly trivial task in Netreo.