1

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)
navicore
  • 1,979
  • 4
  • 34
  • 50
  • 1
    Have you confirmed that you've removed the disk objects associated with all of your disks? See my answer [here](http://stackoverflow.com/a/34364494/272109) for specifics on where these exist, so that you can find and remove them. – David Makogon Jan 02 '17 at 13:56
  • 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 Jan 02 '17 at 14:53

1 Answers1

1

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.

Jason Ye
  • 13,710
  • 2
  • 16
  • 25
  • Thx Jason, I've confirmed there are no containers: https://snag.gy/Qkt26E.jpg Powershell is a problem for me on OSX and Linux. I'll re-try the latest build if I have to but I hope there was another way. – navicore Jan 02 '17 at 16:28
  • @navicore also you can use CLI to list the blob, I've updated the answer. – Jason Ye Jan 03 '17 at 02:35
  • @jason-ye-msft, the cli confirms what the ui says, there is no container. cmd: "azure storage blob list "vhds"" gives "The specified container does not exist." I confirmed that if I set the acct and key to a storage account I'm actively using, it gives me that good account's vhd with the same command. – navicore Jan 03 '17 at 03:04
  • @navicore try CLI: azure storage container list – Jason Ye Jan 03 '17 at 03:17
  • info: No containers found – navicore Jan 03 '17 at 03:20
  • @navicore delete the storage account via the portal, the portal will show the current number of objects per storage service, please check if there are tables or queues? – Jason Ye Jan 03 '17 at 04:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/132147/discussion-between-jason-ye-msft-and-navicore). – Jason Ye Jan 03 '17 at 04:56
  • @navicore here is a workaround, maybe you can create a VM with the storage account, then delete all the VHD, then try to delete the storage account. – Jason Ye Jan 04 '17 at 09:27
  • @navicore You can create a VM with this storage account, then delete the resource group, Please let me know if you would like further assistance. – Jason Ye Jan 11 '17 at 09:28
  • @jason-ye-msft that does not work for me. I'll update the chat. – navicore Jan 11 '17 at 17:15
  • 1
    @navicore I've had the EXACT same issue that you had. And the problematic storage account wasn't showing up when I provision the new VM. But I figured out why, you have to choose a plan that uses the correct storage account tier (normal or premium), and most importantly they have to be in the same region! My storage account was in West US 2, but the new VM was in West US, so it never shows up. – Jonny Lin Mar 06 '17 at 23:59