How to Find and Resize Azure VM with Low CPU Usage

Lower your cloud costs by resizing Azure Virtual Machines with low CPU usage. Follow our step-by-step guide and learn how to avoid idle or unused VM resources.

Patrick Londa
Author
Jul 21, 2022
 • 
 min read
Share this post

Low-usage virtual machines can quickly skyrocket your cloud computing costs. You can save significant money by identifying low-usage virtual machines and reducing their size.

Azure provides various instance types to cater to different workload requirements and resource types. By allocating VMs according to their specialized purpose and workload requirements, you can avoid idle or unused VM resources and, in turn, significantly save your cloud computing costs.

Calculating and optimizing the costs of your VMs is easier with the right tools and services. Microsoft provides Azure Cost Management, Azure Advisor, and Azure Pricing Calculator.

Defining Low CPU Usage

Azure Advisor identifies underutilized virtual machines by monitoring your virtual machine's usage for seven days. Virtual machines have low usage if their network usage is 7 MB or less and CPU utilization percentage is 5% or less averaged over four or more days.

You can configure the average CPU utilization rule on a per subscription basis. It can be set to 5%, 10%, 15%, or 20% — 5% is the default setting.

Blink Automation: Ensure Azure VMs with Low CPU Usage are Reviewed
Blink + Azure
Try This Automation

View Utilization of an Azure VM

To access a virtual machine's performance or utilization insights, perform the following steps.

  1. Log in to the Azure portal and select Virtual Machines.
  2. Select a virtual machine from the list of VMs to view its usage.
  3. In the Monitoring section, select Insights.
  4. Select the Performance tab.

The page shows performance utilization charts, CPU Utilization, Available Memory, Logical Disk Space Used, Logical Disk IOPS, Logical Disk MB/s, Max Logical Disk Used, and Bytes Sent and Receive Rate for each logical disk.

Resizing Azure Virtual Machines with Low CPU Usage

There are multiple ways to resize Azure virtual machines. Virtual machines restart while resizing, so scheduling the restart can reduce disruptions caused by the unavailability.

Resizing a Virtual Machine in Azure Advisor

Azure Advisor provides various cost optimization recommendations.

  1. In the list of recommendations, select the Right-size or shutdown under-utilized virtual machines recommendation.
  2. In the list of VMs, choose one for resizing and select it. Verify the utilization metrics in the details displayed. The potential yearly savings value shows how much you save by shutting down or removing the VM, not by resizing it. 
  3. Make a note of the current VM's size. Now, close the window to see a list of virtual machines.
  4. In the list of VMs, select Resize <FromVirtualMachineSKU> to <ToVirtualMachineSKU>.
  5. Next, there's a list of feasible resize options. Select the cost-effective one that provides the best performance.
  6. Select Resize option.

A notification appears when the VM resizes effectively.

Resizing a Virtual Machine in Azure Portal

  1. Log in to the Azure portal.
  2. Access the virtual machine page.
  3. Select the size option from the left-hand side menu.
  4. Choose a new virtual machine size from the list of available sizes.
  5. Select Resize option.

If the new size is unavailable on the hardware cluster hosting the virtual machine, deallocate the VM before resizing it.

Note: Choose the s version of the virtual machine size that uses premium storage.

Resizing a Virtual Machine in CLI

To resize a VM using the Azure CLI, use the script below. You can also consider switching to a low-code platform like Blink to perform these tasks in a few clicks.

1. You can view the current size of a VM with az vm show. This script lists the VM size of "blinkVM" in the "blinkResourceGroup" region:

az vm show \
--resource-group blinkResourceGroupVM \
--name blinkVM \
--query hardwareProfile.vmSize

2. View the available VM sizes on the hardware cluster hosting the VM using az vm list-vm-resize-options. This script displays VM sizes for "blinkVM" in the "blinkResourceGroup" region:

az vm list-vm-resize-options \
--resource-group blinkResourceGroup \
--name blinkVM --output table

3. If the desired VM size is listed, resize the VM with az vm resize. This script resizes "blinkVM" to the "Standard_D3_v2" size:

az vm resize \
--resource-group blinkResourceGroup \
--name blinkVM \
--size Standard_D3_v2

After the VM restarts, your data disks and OS are remapped. Data on the temporary disk is erased.

4. If the VM size you want is not listed, first deallocate the VM with az vm deallocate. Afterward, you can resize the VM to any available size supported by the region. The following steps deallocate, resize, and start the VM:

# Variables will make this easier. Replace the values with your own.

resourceGroup=blinkResourceGroup
vm=blinkVM
size=Standard_D3_v2 

az vm deallocate \
--resource-group $resourceGroup \
--name blinkVMaz vm resize \
--resource-group $resourceGroup \
--name $vm \
--size $sizeaz vm start \
--resource-group $resourceGroup \
--name $vm

Any dynamic IP addresses assigned to the VM are released during deallocation. The OS and data disks are unaffected.

Automate the Resizing Process with Blink 

As your business and engineering requirements evolve against internal operational needs and external market developments, your resizing efforts should be just as agile.

Whether you want to aggregate reports on your CPU usage or navigate instance migrations, having an easy way to navigate the steps is critical.

With Blink, you can use this automation to regularly identify Azure instances with low CPU utilization and gather details about them.

Blink Automation: Ensure Compute Virtual Machines with Low CPU Utilization are Reviewed in Azure
Blink Automation: Ensure Compute Virtual Machines with Low CPU Utilization 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 CPU utilization below a certain threshold.
  2. Sends the results to a designated email.

You can also customize this automation to add a removal step for low CPU instances 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.

Expert Tip