问题
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?
回答1:
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.
回答2:
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.
回答3:
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.
回答4:
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
- Get-AzurePublishSettingsFile launches manage.windowsazure.com and prompts you to download an XML file that you can be saved anywhere.
- Reference: Get-AzurePublishSettingsFile Documentation
- Get-AzurePublishSettingsFile launches manage.windowsazure.com and prompts you to download an XML file that you can be saved anywhere.
Import-AzurePublishSettingsFile and specify the path to the file just saved.
Import-AzurePublishSettingsFile -PublishSettingsFile '<your file path>'
Show and Remove Disks
Show current disks. (Reference: Azure Storage Cmdlets)
Get-AzureDisk
Quickly remove all disks. (Credit to Mike's answer)
get-azuredisk | Remove-AzureDisk
Or remove disks by name. (Credit to Remove-AzureDisk Documentation)
Remove-AzureDisk -DiskName disk-name-000000000000000000 -DeleteVHD
来源:https://stackoverflow.com/questions/14653421/windows-azure-delete-disk-attached-to-non-existent-vm