Back to Blog

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.

azure-logo

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.

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
StorageBlobLogs
| 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 automate this check to run regularly, produce reports on all the instances that fit the criteria, and leverage no-code/low-code steps to manage and customize your process.

Get started and create your free Blink account today.

Simplify your cloud operations

Sign up for Blink today

Transform your cloud operations today with a library of purpose-built DevOps and SecOps playbooks and hundreds of integrations.

Sign up