Unable to Delete Azure Backup Vault?

This week, I encountered an annoying issue when deleting some resources, specifically Azure Backup Vaults (and recovery service vaults). I was deleting a resource group that contained several resources, including a backup vault. The delete started fine, and all the other resources got deleted, but the vault and the resource group did nothing for a long time before the deletion timed out with no further information.

The issue is that when you attempt to delete a resource group, it attempts to delete all the resources inside it, including the backup vault. However, the backup vault will not let you delete it if any active backups are configured. Whilst this seems like a reasonable protection to avoid accidentally deleting your backups, it does mean that deleting everything by just deleting the resource group no longer works. The resource group delete doesn’t know there are backups that need to be deleted; it won’t try and delete any of these sub-resources; it just tries to delete the vault and then gives up when that doesn’t work. It is not ideal for scenarios where you are just trying to clean up a load of resources or have some automation to do the cleanup.

Resolution

To resolve this issue, delete any configured backups before trying to delete the vault. In the portal, you can go to the vault and then go to the “Backup Instances” tab.

Backup Items

In this window, you should see your backups listed. You may need to change the “Datasource Type” in the drop-down to find them. If you click the ellipsis at the end of the backup, you should see a delete option.

Delete Button

This will then give you a screen to confirm that you want to delete the backup and explain why.

Delete Backup

Complete this for all backup jobs, and you should then be able to delete the vault.

If you’re using automation or don’t want to do this manually, you can do this through Powershell:

Get-AzDataProtectionBackupInstance -VaultName blobvault -ResourceGroupName backup | Remove-AzDataProtectionBackupInstance