Hello Razzi,
I think you might find this article useful.
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/find-unattached-disks#managed-disks-find-and-delete-unattached-disks
First, after connecting with powershell to your Azure instance, run the script by setting the deleteUnattachedDisks variable to 0. This action lets you find and view all the unattached managed disks.
After you review all the unattached disks, run the script again and set the deleteUnattachedDisks variable to 1. This action lets you delete all the unattached managed disks.
# Set deleteUnattachedDisks=1 if you want to delete unattached Managed Disks
# Set deleteUnattachedDisks=0 if you want to see the Id of the unattached Managed Disks
$deleteUnattachedDisks=0
$managedDisks = Get-AzDisk
foreach ($md in $managedDisks) {
# ManagedBy property stores the Id of the VM to which Managed Disk is attached to
# If ManagedBy property is $null then it means that the Managed Disk is not attached to a VM
if($md.ManagedBy -eq $null){
if($deleteUnattachedDisks -eq 1){
Write-Host "Deleting unattached Managed Disk with Id: $($md.Id)"
$md | Remove-AzDisk -Force
Write-Host "Deleted unattached Managed Disk with Id: $($md.Id) "
}else{
$md.Id
}
}
}
Hope this will help.
Best