CostLensAzure VM Right-sizing

Azure VM Right-sizing

CostLens flags over-provisioned Azure virtual machines that could run on a smaller size, and can resize them for you.

Updated August 20262 min read

CostLens flags Azure virtual machines that are over-provisioned — running on a larger size than their workload needs. These VMs are in use but sit at low CPU with no spikes, so they can move to the next smaller size in the same family (e.g. Standard_D4s_v5Standard_D2s_v5) and keep headroom.

Resizing restarts the VM

Changing a VM's size restarts it (~1–3 min). Your disks and data are preserved — only the compute size changes. Apply during a maintenance window and confirm the VM comes back cleanly.

How it works

Azure Monitor CPU is analysed

CostLens reads 14 days of the Percentage CPU metric for each running VM and requires at least a week of observation before making a call.

Over-provisioning is detected

A VM is flagged when its average CPU sits between 5% and 25% and its peak stays under 50% (spiky VMs are skipped). Deallocated VMs — which bill no compute — are excluded, as are VMs too new to judge.

A smaller size is recommended

CostLens recommends the next smaller size in the same family. Savings are the difference between the two sizes' hourly rates.

Confidence: CPU-only

This recommendation is based on CPU utilisation alone (Azure Monitor exposes no guest memory metric by default), so confidence is capped at Medium — confirm the VM has memory headroom before applying.

What to do

  1. Review the recommendation — the current size, the recommended size, and the observed average/peak CPU.
  2. On Apply, choose either the CostLens-recommended size or a different size from the picker (each shows its monthly cost and savings). You keep full control over the final size.
  3. CostLens resizes the VM in place; Azure restarts it to apply the change.
  4. The change is reversible within 24 hours.

If the target size isn't available on the host

An in-place resize can fail if the target size isn't offered on the VM's current host cluster. If that happens, deallocate (stop) the VM in the Azure portal and retry — the target size will then be provisioned on a compatible host.

Required permissions

The standard Reader role (for metrics + VM enumeration) plus a write role covering:

Microsoft.Compute/virtualMachines/write

Limitations

  • CPU-only signal — validate memory headroom before applying.
  • In-place resize requires the target size to be available on the current host cluster (see the note above).
  • AKS node-pool VMs are handled separately by the AKS right-sizing check, not here.
CostLens
Previous
Idle Virtual Machine
CostLens
Next
VM Off-Hours Schedule