Are you unable to delete storage accounts, containers and VHDs in the azure portal? Even when you’ve already deleted the relevant Virtual Machines?
Maybe you’re running into the case that some of your VHDs are still configured as an potential disk for some Virtual Machine. Azure will place a lease on the VHDs in order to avoid accidental deletion.
On https://portal.azure.portal.com, you can’t see these configured disks. On https://manage.windowsazure.com/ you can though.
Go to the ‘Virtual Machines’ item and click in the ‘Disks’ tab at the top of the page. There you see and delete these configured disks
When experimenting in my lab environment I want to create a backup of the virtual machines. The following PowerShell script will do just that. I assume you’ve already setup your PowerShell to work with azure by doing the following:
- Setup the Azure PowerShell cmdlets (see: http://azure.microsoft.com/en-us/downloads/)
- imported your Publish Settings File (see Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFile)
- Defined which storageaccount to use with Set-AzureStorageAccount
- Shutdown all the Virtual Machines
Import-Module Azure -ErrorAction Stop
$backupContainerName = "backups"
$vms = Get-AzureVM
if (! (Get-AzureStorageContainer -Name $backupContainerName -ErrorAction SilentlyContinue) )
New-AzureStorageContainer -Name $backupContainerName -Permission Off
foreach ($vm in $vms)
Write-Host "backing up machine: " $vm.Name
$disks = @()
$disks += $vm | Get-AzureOSDisk
$disks += $vm | Get-AzureDataDisk
foreach($disk in $disks)
$DiskBlobName = $disk.MediaLink.Segments[-1]
$DiskContainerName = $disk.MediaLink.Segments[-2].Split('/')
Write-Host "disk: " $disk.DiskName
#Start an asynchronous copy of the VHD to our backup destination
Start-AzureStorageBlobCopy -SrcContainer $DiskContainerName -SrcBlob $DiskBlobName -DestContainer $backupContainerName -DestBlob $DiskBlobName
#Wait for the copy to complete
Get-AzureStorageBlobCopyState -Blob $DiskBlobName -Container $DiskContainerName -WaitForComplete