Review Azure disks left behind after VM deletion
On this page
Unattached managed disks keep generating storage charges after VM deletion, so list and review each disk before removal. Skipping that review can delete data Azure retained to help prevent accidental loss.
What you need first
- Tool
- Use Azure CLI, Azure's command-line tool, in a Bash session. Start in Azure Cloud Shell, which signs you in automatically, or run az login locally to sign in through a browser.
- Access
- If you cannot list disks in the intended subscription, ask an authorized Azure colleague for the read-only disk list and details.
- If you do not use that tool
- Give an Azure operations colleague the subscription name or ID and this command. Request the returned disk IDs and az disk show details, including LastOwnershipUpdateTime, for each ID.
Why this is worth a look
Skipping this review can leave you paying for unattached disk storage after a VM is deleted. Azure keeps attached disks by default when the VM is deleted, and an unattached managed disk has a null managedBy property. Treat that state as a review candidate, not proof that its data is disposable.
Run these commands
BASHRun this read-only Bash command after Azure CLI authentication. Replace YOUR_SUBSCRIPTION_ID with the intended subscription name or ID. It returns current resource IDs, not costs or historical usage.
#!/usr/bin/env bash
set -euo pipefail
# Replace this value before running the command.
SUBSCRIPTION_ID="YOUR_SUBSCRIPTION_ID"
az disk list \
--subscription "$SUBSCRIPTION_ID" \
--query '[?managedBy==`null`].[id]' \
--output tsvHow to confirm it
- 01
Choose the subscription
Replace YOUR_SUBSCRIPTION_ID with the subscription name or ID you want to review. The explicit --subscription option scopes the command to that subscription instead of the sign-in default.
- 02
Run the read-only inventory
Run the command, or ask your Azure colleague to run it. Record the returned resource IDs. This command lists disks and does not delete them.
- 03
Check when each disk detached
Run az disk show --ids '<complete-resource-ID>' for each result. Read LastOwnershipUpdateTime. For an unattached disk, it shows when the disk became unattached. A blank value can indicate a newly created disk whose state has not yet changed.
- 04
Confirm ownership before removal
Ask the team responsible for each disk's data whether it is still needed. Record keep or investigate-removal decisions, and do not approve deletion from the ID or timestamp alone.
Before making changes
This is a current inventory, not a savings estimate. Assume Azure CLI is authenticated and the placeholder names the intended subscription. The command covers managed disks in that one subscription at execution time, with no historical window. Its output is resource IDs, not storage quantities or billing units.