Windows Azure: Delete disk attached to non-existent VM
Asked Answered
L

5

7

Just found out I was taking up - and paying for - a lot of storage due to abandoned disks from long ago deleted VMs. I manged to delete most of them, but now I'm stuck with a set that cannot be deleted as they remain attached to VMs nowhere to be found.

Any ideas how to get rid of these disks, PowerShell tricks maybe?

Lack answered 1/2, 2013 at 19:13 Comment(1)
If you have recently deleted the VM, for whatever reason, sometimes it takes time for the disk to also be deleted. In this case it will appear in the disks list but the delete functionality will appear to be disabled. In the time it took me to read through the answers in this post, the disk disappeared on it's own.Butterfingers
A
3

If I am understanding correct, Once you delete a Virtual Machine, it delete the service but keep a copy of the VHD image under Disks. So please go to the Disks tab under virtual Machine and try to delete it.

If that is not the case, please add a screenshot with error message from where your trying to delete VM.

Availability answered 4/2, 2013 at 2:7 Comment(2)
No, the VM is long gone, but the disk still seems attached to the - no longer existing - VM. As a result the "Delete" option is greyed, and I'm stuck. I can't delete the VM because it si gone, I can't delete the disk because it is attached to a VM (which is gone), and I can't delete the storage container because it contains data. Therefore I have to pay Microsoft for storing 240 GB of dead disk! I'm new on Stackoverflow, so I'm not allowed to attach images, but here is a link to a screen shot: cl.ly/image/383t2u1q462wLack
Hello flensted, At this point if you are still having issue . Your best option is to open a support ticket with Windows Azure Support . windowsazure.com/en-us/support/contactAvailability
L
1

The only way to do this that I can see is through PowerShell. I ran into the same problem and here's how I fixed it. I installed the Azure PowerShell extensions and configured my subscription and then my storage account. Once I did that I then ran this command

get-azuredisk | Remove-AzureDisk

Get-azuredisk will grab all disks In my case I needed all of them removed. If you need to do individual then you need to get the name of the disk and then run remove-azuredisk with the name switch and specify the disk name to remove it. That fixed it for me. Hope this helps someone in the future.

Lankton answered 5/8, 2015 at 20:16 Comment(0)
S
1

In the "new" Azure portal. Select Storage Accounts, then click on the storage account" where your none used VHD's are located, Click Blobs under Services, Click vhds under Essentials, search for unwanted vhd and click delete.

Serous answered 25/4, 2016 at 20:52 Comment(0)
O
0

I was unable to use the (2016) web portal to delete orphaned disks in my (classic) storage account. The answers here work, but here is a more detailed walk-through for deleteing these orphaned disks with PowerShell.

PowerShell

Download and install PowerShell if you haven't already. (Install and configure Azure PowerShell.) Initial steps from this doclink:

  • Check that the Azure PowerShell module is available after installing:
    Get-Module –ListAvailable

  • If the Azure PowerShell module is not listed, you may need to import it:
    Import-Module Azure

  • Login to Azure Resource Manager:
    Login-AzureRmAccount

AzurePublishSettingsFile

  • Retreive your PublishSettingsFile.
    Get-AzurePublishSettingsFile

  • Import-AzurePublishSettingsFile and specify the path to the file just saved.
    Import-AzurePublishSettingsFile -PublishSettingsFile '<your file path>'

Show and Remove Disks

Orientation answered 22/1, 2016 at 15:30 Comment(0)
D
0

in azure you can erase disks using Azure Storage Explorer.

If you have a deleted virtual machine and the disks report that they are attached and the command gives you an error:

Remove-AzDisk -ResourceGroupName $resourcegroup -DiskName -Force output:

Remove-AzDisk: Disk vmname_OsDisk_1_c2116### is attached to VM /subscriptions/###/resourceGroups/rgname/providers/Microsoft.Compute/virtualMachines/vmname.

ErrorCode: OperationNotAllowed

ErrorMessage: Disk /subscriptions/###/resourceGroups/rgname/providers/Microsoft.Compute/virtualMachines/vmname.
ErrorTarget:
StatusCode: 409
ReasonPhrase: Conflict
OperationID : 34731d70-2f9e-4ad1-8eec-4fcb6f55fbd0

you can create a generation 1 server to test on the same resource group with the same bug name.

with this you make the "Resource ID" exist for the virtual machine,

and you can now erase the disk by Azure Storage Explorer normally.

This is because Azure does a validation prior to deletion and if the disk is attached, the VM must exist.

Deluca answered 1/9, 2022 at 14:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.