Optimizing Costs for Long Running Azure VMs with Reserved Instances

One way to optimize your Azure cloud costs is by finding long running Azure VMs and utilizing Reserved Instances instead. In this guide, we'll show you how.

Patrick Londa
Jul 22, 2022
 min read
Share this post

With Azure virtual machines (VMs), your organization can rapidly scale computing resources on-demand without the cost of maintaining internal hardware. In exchange for the convenience, Azure VMs can cost you a good amount of money so it’s important to be conscious of your resource allocation.

If you have virtual machines that consistently require a lot of time to run tasks, these long running instances can be especially expensive and represent an opportunity to reduce your costs by up to 72% by switching operations to a different instance type based on predictable usage, Azure Virtual Machine Reserved Instances.

In this guide, we will outline how you can save money with Azure by finding your long-running virtual machines and utilizing reserved instances.

Defining Long Running Azure Virtual Machines

Long running Azure virtual machine instances, by definition, are active for long periods of time throughout the day and commonly perform tasks like background website scripts or complex computing calculations. 

These instances could be long running because they are tasked with complex, time-intensive operations. There could also be an issue with long-running operations that have been disrupted or failed. It’s possible that your VM could still be running despite flawed operations and adding to your monthly charge.

Ultimately, your organization can define what long running means to you, as in the number of days since the instances started running. 90 days is a common benchmark.

Blink Automation: Ensure Long Running Azure VMs are Reviewed
Blink + Azure
Try This Automation

Finding Any Long Running Instances

You can locate your long-running instances with Azure Monitor. Azure Monitor is a product offering from Microsoft that allows you to analyze resource performance.

You can run log queries to get information about long running virtual machines and the types of operations they are running. In this example, there’s a query that shows the operation of a resource over the last 3 days.

Source: Azure Tutorial – Collect and analyze resource logs from an Azure resource
| where TimeGenerated > ago(3d)
|summarize count() by OperationName
|sort by count_desc
| render piechart

You can use a query like this one and adjust the “TimeGenerated” parameter to “TimeGenerated > ago(90d)” to focus on long running instances. There are lots of query types to choose from in Azure Monitor.

Applying Azure Virtual Machine Reserved Instances

After you’ve checked for performance issues, you might find that your instances are healthy and just need time to run your operations. In cases like these, you can consider reducing your costs by applying a reserved instance

You can use an RI without having to rebuild your VM from scratch. An Azure RI is a VM on the public Microsoft Azure cloud. It is for dedicated use for one to three years and can be purchased with a one-time up-front payment. This can discount your subscription by 72%. That means that if you purchase a 1 year term of Reserved Instances and achieve this ~70% savings, your purchase will break even in a few months and then you’ll see significant cost savings for the rest of the year.

To buy reserved instances:

  1. Go to the Azure portal.
  2. Navigate to "All Services" and select "Reservations."
  3. From here, you can click "Add" to purchase the new reservation.
  4. Select "Virtual Machine."
  5. Enter the required fields and define a scope.

The RI discount will be applied at the subscription level as opposed to individual VMs. Your number of qualifying VMs depends on the scope you select. After purchasing the RI and getting a discount on your subscription, you can move qualifying VMs to the discounted subscription by doing the following:

  1. Manage the resource group containing your VM in the Azure portal. Search for "Resource Groups" to find the VM to move.
  2. Select the resource group containing your VM.
  3. At the top of the page, click on "Move" and then "Move to another subscription" to open the "Move resources" page.
  4. Select the related resources you wish to move. Usually, you should select all of the related resources listed.
  5. Select the subscription with the reserved-instances discount.
  6. Select an existing resource group or create a new resource group to put your VM resources in.
  7. Confirm that you understand that new resource IDs will be used for your VM and click "OK."

This will then move your existing long-running Azure virtual machine to a reserved instance. Repeat the above steps for any other VMs you wish to move and remember that the VMs must match the scope you selected when purchasing the RI.

Automatically Identify Long Running Instances with Blink 

Before you can make decisions about how to handle a long running instance, you need information about which instances qualify, what their usage data looks like, and the related business-impacts. If it’s hard to get a picture of that data, you might not make any decisions on potential improvements.

Instead of manually searching through your Azure console or scripting a query, there’s an easier way to aggregate reports and take action on long running instances.

With Blink, you can use this automation to regularly identify long running Azure instances and gather details about them.

Blink Automation: Ensure Long Running Virtual Machines are Reviewed in Azure
Blink Automation: Ensure Long Running Virtual Machines are Reviewed in Azure

When this automation runs, it executes the following steps:

  1. Checks your Azure account to see if there are any virtual machines that have been running longer than a certain number of days.
  2. Sends the results to a designated email.

You can also customize this automation to add a removal step for old snapshots if approved via Slack.

There are over 5K automations in the Blink library you can use right away, or you can build new automations from scratch with drag-and-drop actions to fit your unique use case.

Get started with Blink today to see how easy automation can be.

Automate your security operations everywhere.

Blink is secure, decentralized, and cloud-native. 
Get modern cloud and security operations today.

Get a Demo