How to reboot Azure VM Scale Sets on schedule?

Azure VM Scale Sets allows users to configure a set of ubiquitous VMs in the Azure cloud that share configuration and are treated as a single unit from the logical perspective, e.g. they’re automatically load-balanced. VM Scale Sets is also the technology underneath Microsoft’s Azure Service Fabric and Azure Batch.

Netreo is a cloud monitoring and management tool, that provides powerful monitoring, automation and auto-scaling functionality for Azure VM Scale Sets, you can learn more about it here.

In this article, we’ll see

  • How to keep VM Scale Sets performing optimally, by rebooting their instances one at a time, once per day. Regular reboots can help mitigate common causes of performance degradation, such as memory leaks, connections that weren’t properly closed and disposed, etc.
  • How to automatically shutdown VM Scale Sets on a schedule in order to save costs.
  • Another way to save money is to auto-scale VMs Scale Sets described in this article.

To automatically shutdown and reboot VM Scale Sets:

1. Run Netreo Setup Wizard to connect to your Azure environment

If you aren’t using Netreo yet, sign up for a free account, then authorize Netreo to view your Azure subscription with VM Scale Sets. Learn more about the setup process here.

2. Activate the Daily Reboot action

To simplify configuration Netreo comes with a set of monitoring templates that define popular metrics, alerts, and automation. Default template for VM Scale Sets already contains the “Daily Reboot” action that will reboot every VM in the set once per day. Tick the “Enabled” checkbox to activate the action. Rebooting of instances is done one-at-a-time, at the top of every hour, starting at UTC 0.  Rebooting instances one at a time ensures that VM Scale Set continues to be up and running.

reboot Azure VM
3. Define Shutdown and Start actions

If your application running on VM Scale Sets is not needed during off hours, cost savings of shutting down the Scale Set can be substantial.

Technical consideration to note: when a VM in a ScaleSet is shut down, its IP is deallocated. When it is brought back up, it will get a new IP unless it is assigned an Azure Reserved IP.

To shutdown VM Scale Sets during off hours:

  • In the configuration dialog for VM Scale Sets go to the “Actions” tab.
  • Define a new action executed according to a schedule. As an example, the schedule will trigger action every day or every working day, at approximately 5 pm. Learn more about schedules here.
  • Ensure that “Evaluate this condition by individual instance?” checkbox is NOT ticked. From the “Execute Command” drop-down select “AzureVMScaleSetStopDeallocate” action (screenshot below).

reboot Azure VM
To activate VM Scale Sets during working hours:

  • In the configuration dialog for VM Scale Sets go to the “Actions” tab.
  • Define a new action executed according to a schedule. The schedule would trigger action every day or every working day, at approximately 9 am.
  • Ensure that “Evaluate this condition by individual instance?” checkbox is NOT ticked. From the “Execute Command” drop-down select “AzureVMScaleSetStart” action (screenshot below).

In this article, we explained how to activate the “Daily Reboot” action and how to shut down/restart VM Scale Set according to a schedule. Netreo can also execute and auto-scale VM Scale Sets based on signals captured anywhere in the Azure environment, e.g. CPU and memory utilization, ASB queues lengths, etc. Learn more in this article.

Find Out how Netreo can help with all Azure monitoring needs. Request a Demo Today

Ready to get started? Get in touch or schedule a demo.