MANAGE the cloud: Automatically shut down Azure VMs

After you PLAN your migration and make the MOVE to the cloud, it’s now time to optimize how you use it. So in our MANAGE series, we’re talking about best practices to optimize how you use the Microsoft cloud. 

When it comes to managing Azure, one of the key things is to use resources only when you need them. With the cloud, you have the option to shut unused resources down. This is particularly true for Azure Virtual Machines, which you can easily shut down and restart—with no loss of data.

Microsoft estimates that many organizations can turn off (or at least deallocate) their non-production virtual machines for more than 70% of the time. This can then reduce costs by 70%, too. So a helpful exercise is to understand exactly when your users need each of your virtual machines. Is it only certain hours of the workday? Is it only on certain days of the week? Knowing specific answers to these questions is critical to maximize your potential savings.

You should also understand the two ways to stop a virtual machine:

  • Stopped (allocated): When you shut down a virtual machine from within the virtual machine OS, it keeps the machine allocated to your organization. This is where the underlying infrastructure (like CPU and memory) is still reserved for the virtual machine. Thus, you’ll still get billed for this resource.
  • Stopped (deallocated): When you stop a virtual machine from the Azure portal or other Azure tools, it also deallocates the machine. That means you’ll no longer be billed for the resource, which can save you significant costs (though other resources like VM disks associated with the VM might still be charged).

So for maximum cost savings, you need to both stop and deallocate your virtual machines. And you have a few options for how you can make this happen.

Option 1: Do an auto shut down of VMs

The Azure portal offers a built-in way for you to automatically shut down virtual machines. Microsoft originally introduced this feature as part of DevTest Labs, and it quickly became the #1 policy used in DevTest. So they decided to roll it out across all Azure virtual machines.

Here’s how it works: You schedule a time each day when a virtual machine will stop. At that time, Azure automatically stops the machine and deallocates it. Microsoft also stops billing your subscription for the compute time, until you decide to restart the machine. You can even choose to be notified by email (or other means) before the machine stops. This can give users a chance to save their work and not be forced out of their machines unexpectedly.

 Cloud Management: Azure Virtual Machine | Binary Tree

Image source: Microsoft

Side note: Interestingly, there’s no corresponding auto start-up feature. So you’ll need to restart these virtual machines manually. That’s why one of the options below might be a better choice, as they offer more flexibility to both stop and start.

Option 2: Create a runbook in Azure automation

You can automatically shut down and restart Azure virtual machines using a runbook executed in Azure Automation. This is the most flexible option, but it also requires the most technical expertise to set up. Specifically, you’ll need to be comfortable working with PowerShell cmdlets to get the results you want. Here’s a post from Codehollow that walks you through the steps to do it. Or if you’d prefer a solution in which someone has already done the configuration for you, see option 3.

Option 3: Use a third-party tool to start/stop during off hours

Last up, the most complicated—yet also most powerful—option is an Azure Marketplace solution called Start/stop VMs during off hours. This tool lets you start and stop VMs on a schedule or based on how they’re being used. It also sends you emails when your machines start and stop, plus shows logs of all start/stop events. And you can apply this policy to your entire subscription, rather than just individual virtual machines.

 

Azure Cloud Management Service | Binary Tree

Image source: Microsoft

Get started

Need help managing the Microsoft cloud? We at Binary Tree are standing by. We offer a range of managed services that mitigate the risks and take the guesswork out of adopting, managing, and leveraging the power of the Microsoft cloud. To get started, get in touch.

 

Source: Microsoft. Cloud Migration and Modernization Playbook. 2018.