Published 21 October 2026 · Updated 3 November 2026 · By Sonu Kumar (opens in a new tab), Data engineer, Zoorik

Short answer. Query Azure Resource Graph for managed disks whose disk state is Unattached. Each one is still charged for its provisioned size, unless it’s empty and was never used. Price them, check with their owners, take an incremental snapshot, then delete what nobody needs.
Why unattached disks cost money
Picture a VM someone deleted last quarter. Its 1 TiB Premium SSD data disk wasn’t set to delete with it, so the disk still sits in its resource group. Nothing reads it.
A 1 TiB Premium SSD is a P30 by default, one of the fixed Azure disk sizes. It’s charged at the P30 tier, with or without a VM, until someone deletes it.
When you delete a VM, Azure keeps its disks by default, to guard against losing data to a mistaken delete. Microsoft adds that “you will continue to pay for unattached disks.”
Unattached disks usually come from one of three places:
- Deleted VMs. A deleted VM leaves its disks, NICs and public IPs behind unless their delete option is Delete. VMs created with the Azure CLI or PowerShell detach their OS disk on delete by default.
- Disks detached by hand. A disk detached after a migration, or left over after you shrink a managed disk by copying, stays until someone deletes it.
- Kubernetes volumes. A volume with the Retain reclaim policy leaves its disk behind after its PersistentVolume is deleted.
One kind costs nothing: an empty disk that was never used. Azure allocates its storage only on first use, such as its first attach or upload.
Disk states you pay for
Every managed disk has a diskState property. Attached, Reserved, Frozen and Unattached disks are all charged for their provisioned size, except the empty, never-used kind.
| diskState | What it means (Azure Compute API) |
|---|---|
Attached | The disk is currently attached to a running VM. |
Reserved | The disk is attached to a stopped-deallocated VM. |
Frozen | The disk is attached to a VM which is in hibernated state. |
Unattached | The disk is not being used and can be attached to a VM. |
ActiveSAS | The disk currently has an Active SAS Uri associated with it. |
ActiveSASFrozen | The disk is attached to a VM in hibernated state and has an active SAS URI associated with it. |
ReadyToUpload | A disk is ready to be created by upload by requesting a write token. |
ActiveUpload | A disk is created for upload and a write token has been issued for uploading to it. |
A Reserved disk belongs to a deallocated VM, so it never shows in an unattached list. Review any VM left deallocated for months.
One query for every subscription
Resource Graph reads across subscriptions, so one query replaces a loop of az disk list calls. Save it as unattached-disks.kql:
Resources
| where type =~ 'microsoft.compute/disks'
| where tostring(properties.diskState) =~ 'Unattached'
| project id, name, subscriptionId, resourceGroup, location,
diskState = tostring(properties.diskState),
diskType = tostring(sku.name),
tier = tostring(properties.tier),
sizeGiB = toint(properties.diskSizeGB),
osType = tostring(properties.osType),
createOption = tostring(properties.creationData.createOption),
unattachedSince = todatetime(properties.LastOwnershipUpdateTime),
created = todatetime(properties.timeCreated),
tags
| order by sizeGiB descA row with createOption set to Empty and a blank date may never have been attached, so it may cost nothing. Confirm it in Cost analysis before you count it as free.
To keep only disks detached more than 30 days ago, add | where unattachedSince < ago(30d) as the last line. That filter drops the blank-date rows, so review those separately.
The query leaves out disks in ActiveSAS, ReadyToUpload or ActiveUpload, which have an open export link or a pending upload.
managedBy holds the ID of the VM a disk is attached to. To list every disk with an empty managedBy, swap the second where line for | where isempty(managedBy). Then check each row’s diskState before you act on it.
In the Azure portal
Open Resource Graph Explorer, paste the query and run it. Azure Advisor’s Cost tab also lists these disks. Its preview recommendation reads: “Review disks that aren’t attached to a VM and evaluate if you still need the disks.”
With the Azure CLI
az graph query comes from the resource-graph extension, which installs on first use, or with az extension add --name resource-graph. Without --subscriptions, it queries every subscription you can access. --first takes 1 to 1,000 rows per call:
$ az graph query -q "$(cat unattached-disks.kql)" --first 1000
The disks come back in the data array of the JSON. For a quick read, add --query data --output table.
Don’t use --output table alone: table output skips nested objects, so the disk rows don’t appear. It also hides the id column, so take disk IDs from the JSON.
For one subscription, az disk list can test managedBy instead:
$ az disk list --query '[?managedBy==`null`].[id]' -o tsv
With PowerShell
Search-AzGraph, from the Az.ResourceGraph module, runs the query across every subscription you can access in the current tenant when you add -UseTenantScope. Its -First takes 1 to 1,000:
Search-AzGraph -Query (Get-Content -Path ./unattached-disks.kql -Raw) ` -UseTenantScope -First 1000
What unattached disks cost
For what you were charged, open Cost analysis in Microsoft Cost Management. Filter to the managed disk resource type, group by resource, and match the rows to the query’s disk IDs.
For a forward estimate at list price, group the same disks by type, tier, size, provisioned performance and region:
Resources
| where type =~ 'microsoft.compute/disks'
| where tostring(properties.diskState) =~ 'Unattached'
| summarize disks = count() by
diskType = tostring(sku.name),
tier = tostring(properties.tier),
sizeGiB = toint(properties.diskSizeGB),
iops = toint(properties.diskIOPSReadWrite),
mbps = toint(properties.diskMBpsReadWrite),
location
| order by disks descMultiply each row’s count by that tier’s monthly price in that region, from the managed disks pricing page. Prices vary by region and change, so check them on the day.
- Premium SSD. Charged at its performance tier.
- Standard SSD and Standard HDD. Charged at the tier their provisioned size falls in. In Microsoft’s example, a Standard SSD grown from 1 TiB to 3 TiB is charged at E50.
- Ultra Disk and Premium SSD v2. No tiers: they’re charged per GiB, so price them from
sizeGiBplus theiopsandmbpscolumns. An Ultra Disk’s price rises with its provisioned IOPS and throughput. A Premium SSD v2 is charged for IOPS above 3,000 and throughput above 125 MB/s.
For one disk’s monthly list price, use the Azure disk pricing calculator.
Four checks before you delete
An unattached disk can still hold someone’s data. Check four things first.
- Kubernetes volumes. A disk behind a PersistentVolume detaches whenever no pod uses it. If the volume is
Bound, a claim still owns the disk, so leave it. If it’sReleased, its claim was deleted and the disk is yours to review. This lists each volume’s disk, claim and phase:
$ kubectl get pv -o custom-columns=\ NAME:.metadata.name,DISK:.spec.csi.volumeHandle,\ CLAIM:.spec.claimRef.name,PHASE:.status.phase
- Site Recovery replicas. Advisor’s recommendation “excludes unattached replica disks associated with Azure Site Recovery,” so leave the disks your recovery setup created.
- OS disks. A row with an
osTypeis an operating system disk, such as a deleted VM’s. If anyone might rebuild that VM, keep the disk until its owner decides. - The owner’s call. Read the resource group and the tags, and ask the owner. Tag each disk you keep with the command below, then add
| where isempty(tostring(tags.keep))to the query so the next run skips it.
$ az disk update --name <disk-name> --resource-group <resource-group> \ --set tags.keep=true
Snapshot, then delete
Advisor’s recommendation gives the routine: “Create a snapshot before deletion and confirm the data is no longer needed.” Make the snapshot incremental.
An incremental snapshot is stored on Standard HDD whatever the disk type, and charged for its used size only. It’s a resource of its own, so it stays after you delete the disk. As the Azure disk snapshot cost guide explains, the first one is a full copy, so you pay for all the data the disk holds.
- Take the snapshot, in the same subscription as the disk.
$ az snapshot create -g <resource-group> -n <snapshot-name> \ --source <disk-id> --incremental true
- For Premium SSD v2 or Ultra Disk, wait for the background copy. Unless you enabled instant access when you took it, the snapshot can’t create a disk until
completionPercentreads 100. Snapshots of other disk types always report 100.
$ az snapshot show -g <resource-group> -n <snapshot-name> \ --query "[completionPercent]" -o tsv
- Delete the disk. In Advisor’s words, “Deleting a disk is irreversible.” The
--yesflag skips the confirmation prompt, so check the ID twice.
$ az disk delete --ids <disk-id> --yes
- Tag the snapshot with a review date, and delete it once the owner confirms nobody needs the data.
$ az snapshot update -g <resource-group> -n <snapshot-name> \ --set tags.reviewOn=<yyyy-mm-dd>
In PowerShell, the same steps are New-AzSnapshotConfig -Incremental with New-AzSnapshot, then Remove-AzDisk -Force, which deletes without asking.
Stop new orphaned disks
Pass --os-disk-delete-option Delete and --data-disk-delete-option Delete to az vm create. Deleting the VM later then deletes its disks and their data with it.
For an existing VM, this PowerShell sets the option in place. It is Microsoft’s example from its delete guide, without the network interface line:
$vmConfig = Get-AzVM -ResourceGroupName "<resource-group>" -Name "<vm-name>"
$vmConfig.StorageProfile.OsDisk.DeleteOption = 'Delete'
$vmConfig.StorageProfile.DataDisks | ForEach-Object { $_.DeleteOption = 'Delete' }
$vmConfig | Update-AzVMShared disks are the exception: their delete option can only be Detach or blank. Check them by hand after you delete the VMs that share them.
Where Amoeba fits
A disk-state query can’t see the other space you pay for and don’t use: attached data disks provisioned past the data they hold. Amoeba works on that part.
Amoeba moves a VM’s data disks onto one btrfs pool sized to your data, then rightsizes the pool without any downtime. It grows the pool before it fills. When your data goes down and stays down, it shrinks the pool one disk at a time.
Amoeba doesn’t leave the disks it frees behind as unattached disks:
- A disk a shrink empties. Amoeba moves its data onto the other pool disks, then detaches and deletes the empty disk, with no snapshot.
- The original disks. Once the switch to the pool is checked, Amoeba detaches each original disk, snapshots it and deletes the disk. It keeps each snapshot for 7 days, then deletes it too, and only ever deletes its own.
- Every other disk. Amoeba works only on the data disks of running VMs, never the OS disk. Apart from its own original disks during cleanup, the disks your query found stay yours to review.
Run the query while a move finishes, and an original disk can show as Unattached between its detach and its deletion. You pay for both sets of disks only while the move runs, then for the snapshots while they’re kept.
Azure managed disk cost optimization covers the move and what a VM needs.
Sources: Microsoft Learn, “Azure CLI - Find and delete unattached managed and unmanaged disks” (opens in a new tab); Microsoft Learn, “Disks - Get - REST API (Azure Compute)” (opens in a new tab); Microsoft Learn, “az graph” (opens in a new tab); Microsoft Learn, “Output formats for Azure CLI commands” (opens in a new tab); Microsoft Learn, “Search-AzGraph (Az.ResourceGraph)” (opens in a new tab); Microsoft Learn, “Understand Azure Disk Storage billing” (opens in a new tab); Kubernetes, “Persistent Volumes” (opens in a new tab); Microsoft Learn, “Create an incremental snapshot” (opens in a new tab); Microsoft Learn, “Delete a VM and attached resources” (opens in a new tab); Microsoft Learn, “Cost recommendations - Azure Advisor” (opens in a new tab).