Why can’t I remove my storage account ?

You may want to remove a storage account you’ve created and get a message like this one:

Storage account <mystorage> has container(s) which have an active image and/or disk artifacts. Ensure those artifacts are removed from the image repository before deleting this storage account.

Here is what you may want to check. In the management portal https://manage.windowsazure.com, Storage, <mystorage>, Containers, check the content of your containers, especially the “vhds” one which contains virtual hard disks by default. Here is an example of the portal with stockageazure3 instead of <mystorage>

image

By clicking on the imagearrow near vhds (or each any other container), you’ll find a list of the blobs inside the container. VHD are good candidates for lock, and we’ll see why in a minute.

Select a .vhd blob and click EDIT at the bottom of the screen
image

this will show you the lock:

image

So where do I unlock?

This is related to the way Virtual Machines Work in Windows Azure. The OS disk and data disks live in Windows Azure blob storage. Here is an image of that (here with Windows VMs, but this is very similar with Linux VMs):

image

So VHD blobs are virtual hard disks that may be used by virtual machines; Windows Azure doesn’t want you to remove a virtual machine disk without knwoing about it! The locks are handled by images, and disks, that you can find here:

image

for an image or a disk, you can see the referenced blob in the LOCATION column. Here is an example:

image

in this example, myCentoOSImage references the bueearwy.zbn201304031550350920.vhd blob in the vhds container of the northeurope2affstorage storage account. Thus the URI of https://northeurope2affstorage.blob.core.windows.net/vhds/bueearwy.zbn201304031550350920.vhd.

At the bottom of the screen, you can remove the image and optionally also remove the associated VHD:

image

Same for DISKS

A disk or an image may itself be locked by a virtual machine instance. In such a case, you may have to stop and remove the virtual machiane first.

For example, in the following screen shot, the benjguinu1 virtual machine holds the benjguinmisc-benjguinu1-0-201310042100440782 disk which locks itself the https://stockageazure2.blob.core.windows.net/vhds/benjguinmisc-benjguinu1-2013-10-04.vhd blob.

image

So we have

image

and you cannot remove the referenced blobs without removing the disks, images and VM involved in that chain.

Smile

Benjamin (@benjguin)