1
votes

I've used Azure cli v2 to delete a resource group.

All resources get deleted except a single storage account.

There are no other resources in the subscription, no containers in the storage account, yet I get the "in use" error when I try to delete the storage account.

enter image description here (there are 2 storage accounts now because I've managed to create this situation twice now - neither is deletable)

Steps take so far:

  • I've confirmed there are no disks or images assigned to any VMs via the classic console, the arm console, and the az cli.
  • I've deleted VHDs I found in the storage account, then retried the storage account delete but get same in use error.
  • I've tried to delete via the cli as well as web console (both arm and classic)
1
Have you confirmed that you've removed the disk objects associated with all of your disks? See my answer here for specifics on where these exist, so that you can find and remove them.David Makogon
Yes, "Nothing to Display" on the "OS disks (classic) menu. But thx, I didn't know about that menu - was going to the classic portal before.navicore

1 Answers

1
votes

According to the error message, you can use PowerShell to list all the VHDs in the storage account, here is the script:

Login-AzureRmAccount
$RGName = "jason"
$SAName = "jasondisks690"
$ConName = "vhds"
$TempObj = New-Object -TypeName PSCustomObject
$TempObj |Add-Member -Name BlobName -MemberType NoteProperty -Value $null
$TempObj |Add-Member -Name LeaseState -MemberType NoteProperty -Value $null
$Keylist = Get-AzureRmStorageAccountKey -ResourceGroupName $RGName -StorageAccountName $SAName
$Key = $Keylist[0].Value
$Ctx = New-AzureStorageContext -StorageAccountName $SAName -StorageAccountKey $Key
$List = Get-AzureStorageBlob -Blob *.vhd -Container $ConName -Context $Ctx
$List | ForEach-Object { $TempObj.BlobName = $_.Name; $TempObj.LeaseState = $_.ICloudBlob.Properties.LeaseState; $TempObj }

replace the $RGName $SAName $ConName with your name. enter image description here Also, we can via new portal to check the storage account, and delete all container.

enter image description here

UPdate:

Here is a workaround:
1. creating a new VM in the same Resource Group as the problematic Storage Account. 2. Added the drive to the same Resource Group, same region, etc. 3. After creation I deleted out the new VM, then deleted out the VHD container for the VM in the problematic Storage Account. 4. After this I was able to remove the problematic Storage Account.