Azure: delete unattached managed disks

Deleting an Azure VM does not delete its disks, and an Unattached disk keeps billing. How to list them with az disk, snapshot, delete and prevent them.

Deleting a VM does not delete its data disks: they stay Unattached and Azure keeps billing them by provisioned size.

Policy at a glance

Provider
Azure
Resource
Azure managed disks (Premium SSD, Premium SSD v2, Standard SSD, Standard HDD, Ultra Disk).
What to check
Disks with an empty managedBy, which the portal shows as Disk state = Unattached.
Risk
Low with a snapshot first. Microsoft warns it plainly: deleting a disk is permanent.
Effort
Low: one query per subscription and one delete per disk.

Why it matters: the disk outlives the VM and keeps billing

The Azure documentation is explicit: when you delete a virtual machine, by default the attached disks are not deleted. It protects against data loss from an accidental deletion, at a price: after the VM is deleted, you keep paying for the unattached disks.

And they are paid by provisioned size, not by data written. Premium SSD, Standard SSD and Standard HDD are billed by performance tier, which is set by the capacity you choose (a 1 TiB disk is P30, E30 or S30). The disk types page adds that billing is prorated hourly from the tier's monthly price, regardless of how much data the disk holds. Premium SSD v2 and Ultra Disk are billed per GiB plus the IOPS and throughput provisioned above the baseline.

For a sense of scale, Azure's public price API (Azure Retail Prices, queried on 15 November 2026, East US region, pay-as-you-go) returns USD 19.71 per month for a Premium SSD P10 LRS and USD 9.60 for a Standard SSD E10 LRS, both 128 GiB. A P10 forgotten for a year is over USD 230 for a disk that reads and writes nothing.

The exception: a freshly created empty disk that was never attached and never received data has no storage allocated yet, and according to Microsoft it incurs no charges until its first use.

How to find them

In the portal: search for Disks, open the disk and confirm Disk state says Unattached. The list view lets you add the state column and sort by it.

With the official CLI, Microsoft's script relies on the managedBy property: when the disk is attached it holds the VM ID, and when it is not it is null. This query lists the ones in the active subscription:

az disk list \
  --query "[?managedBy==null].{Name:name,Group:resourceGroup,GiB:diskSizeGb,SKU:sku.name}" \
  --output table

To decide, add when it came loose: az disk show --ids <id> --query LastOwnershipUpdateTime returns when its state last changed, which for an unattached disk is the moment it was detached. The resource group and the tags usually tell you whose it was.

How to fix it, step by step

Terraform example: prevent and back up

With the azurerm provider, delete_os_disk_on_deletion = true in the features block makes azurerm_linux_virtual_machine and azurerm_windows_virtual_machine delete their OS disk when the VM is destroyed (it is the default; writing it makes the intent visible). Data disks are best declared in the same state as their attachment, so they are destroyed together. The second half snapshots an existing orphan disk before deleting it.

provider "azurerm" {
  features {
    virtual_machine {
      delete_os_disk_on_deletion = true
    }
  }
}

variable "resource_group" { type = string }
variable "location" { type = string }
variable "vm_id" { type = string }

# Prevent: the data disk and its attachment live in the same state.
resource "azurerm_managed_disk" "datos" {
  name                 = "app-datos"
  resource_group_name  = var.resource_group
  location             = var.location
  storage_account_type = "StandardSSD_LRS"
  create_option        = "Empty"
  disk_size_gb         = 128
}

resource "azurerm_virtual_machine_data_disk_attachment" "datos" {
  managed_disk_id    = azurerm_managed_disk.datos.id
  virtual_machine_id = var.vm_id
  lun                = 0
  caching            = "ReadWrite"
}

# Fix: incremental snapshot of an orphan disk before deleting it.
data "azurerm_managed_disk" "huerfano" {
  name                = "disco-sin-adjuntar"
  resource_group_name = var.resource_group
}

resource "azurerm_snapshot" "antes_de_borrar" {
  name                = "disco-sin-adjuntar-final"
  resource_group_name = var.resource_group
  location            = var.location
  create_option       = "Copy"
  source_uri          = data.azurerm_managed_disk.huerfano.id
  incremental_enabled = true
}

Validated with terraform validate (Terraform 1.17.2, hashicorp/azurerm provider 4.81.0).

How Control Cloud surfaces it

Control Cloud reads every disk with its managedBy and its usage state. An Unattached disk shows up in the disks tab as idle, with the warning that it keeps billing and "Unattached" in the VM field, and the "Orphans" filter gathers all of them in the region. On the canvas, a disk with a VM hangs from it and one without is flagged on its own.

When not to apply it

Frequently asked questions

Does Azure bill a managed disk that is not attached to any VM?

Yes. Microsoft says so in the unattached disks guide: after a VM is deleted you keep paying for its disks. They are billed by provisioned size, prorated hourly, regardless of how much data they hold.

Why doesn't Azure delete the disks when I delete the VM?

To prevent data loss from an accidental VM deletion. That is why they have to be deleted separately, or set to be deleted with the VM when you create or delete it.

How do I know how long a disk has been unattached?

With az disk show and the LastOwnershipUpdateTime property: on an unattached disk it shows when it was detached. On new disks it stays blank until their state changes.

Does the snapshot I take before deleting cost as much as the disk?

No. Snapshots are billed by used size: a full snapshot of a 500 GiB disk with 50 GiB in use is billed for 50 GiB, and incremental ones store only the differences on Standard HDD storage.

Related policies: Azure: remove unassociated public IPs · AWS EBS: delete unattached volumes · OCI: delete unattached block volumes

Glossary terms: Snapshot · Compartment / Resource Group · Terraform

Official sources

  1. Azure — Find and delete unattached disks (portal)
  2. Azure — Find and delete unattached disks (CLI)
  3. Azure — Understand Azure Disk Storage billing
  4. Azure — Managed disk types
  5. Azure Retail Prices API
  6. Azure — Delete a VM and its attached resources

Ready to see it on your own infrastructure? Book a demo · Read the documentation