0

We wanted to delete a resource group that contained a VM with IP and storage account etc.

Everything got deleted except the storage account because of a vhd which says it still has a lease. I can't break the lease because of the following error message:

Failed to break lease on 1 out of 1 blob(s):
VM2X-20170518-074152.vhd: This blob is being used by the system.

Is there a way to break the lease, delete the blob with the lease active, or find out where it is leased to?

Additional Info: On the vhd on the "Edit blob" tab, I get the following message:

File size of '137.44GB' exceeds max supported file size of '2.1MB.'
Dominik G
  • 1,459
  • 3
  • 17
  • 37
  • Have you looked under "Disks"? (you can search via All Resources in the portal) - then you can try deleting the disk in question. I answered a similar question [here](https://stackoverflow.com/a/34364494/272109) - note - that was from a few years back, and the portal looked a bit different... – David Makogon Mar 10 '19 at 04:07

2 Answers2

1

This sounds like a familiar problem with classic storage accounts, if it's the problem I think it is you will need to delete image using Powershell.

Set Storage account

$storageAccountName = "your storage account"

Check OS Disk image

Get-AzureVmImage | Where-Object { $_.OSDiskConfiguration.MediaLink -ne $null -and $_.OSDiskConfiguration.MediaLink.Host.Contains($storageAccountName)`
                           } | Select-Object -Property ImageName, ImageLabel

Check Data Disk image

Get-AzureVmImage | Where-Object {$_.DataDiskConfigurations -ne $null `
                                    -and ($_.DataDiskConfigurations | Where-Object {$_.MediaLink -ne $null -and $_.MediaLink.Host.Contains($storageAccountName)}).Count -gt 0 `
                                   } | Select-Object -Property ImageName, ImageLabel

Remove any image

Remove-AzureVMImage -ImageName 'yourImageName'

Note: commands are classic/ASM, make sure you have module installed.

Hannel
  • 1,656
  • 3
  • 10
  • 17
  • Thanks, that might have helped, I got it deleted by migrating it to ARM and deleting it then, so I can't test your solution. – Dominik G Mar 10 '19 at 07:58
  • Then, that was your issue . You have to perform above steps to migrate. – Hannel Mar 10 '19 at 22:05
0

yes, you can use portal UI or powershell to break the lease (or SDK's). for the portal just click on the blob and there would be a button to break the lease. for powershell something like this:

$blob = Get-AzureStorageBlob -Context $ctx -Container %container% -Blob %blob%
$blob.ICloudBlob.BreakLease() 
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thank you, I tried in the portal but got the error message above. I'll try in Powershell. – Dominik G Mar 07 '19 at 14:07
  • you dont need to edit blob, you need to go to the storage account, find the blob, click on it and click break lease button – 4c74356b41 Mar 07 '19 at 14:16
  • Thank you, I broke the lease there but tried to delete the vhd afterwards instead of the blob – Dominik G Mar 07 '19 at 14:45
  • vhd is a blob. anything in azure blob storage is a blob. so your problem solved? – 4c74356b41 Mar 07 '19 at 14:51
  • Sadly not. I deleted the container now but when I want to delete the Storage Account I get the error message `Storage account "search5022" cannot be deleted: "The storage account "search5022" has some active images and/or media, e.g. "WkV25326-WkV2-0-201705180543020779". Remove these images and/or media before deleting this storage account.". (Code: StorageAccountOperationFailed)` – Dominik G Mar 08 '19 at 13:03
  • delete those as well :) – 4c74356b41 Mar 08 '19 at 13:17
  • There is no more container or blob inside the storage account. I'd delete them if I could find them – Dominik G Mar 08 '19 at 13:19
  • I neither have any VMs/Images or blobs left. There's only AzureDevOps and Azure AD left in the account. – Dominik G Mar 08 '19 at 13:26
  • I got it deleted now by migrating it to ARM and then deleting both the new resource group and the old resource group. – Dominik G Mar 08 '19 at 14:28