Daniel's Tech Blog

Cloud Computing, Cloud Native & Kubernetes

Deletion of Azure Recovery Services Vault used for Azure SQL Database backups fails

Maybe you stumbled over this behavior. You are using a Recovery Services Vault to store Azure SQL Database backup for long-term retention.

-> https://docs.microsoft.com/en-us/azure/sql-database/sql-database-long-term-retention

When you have deleted the Azure SQL Database before you disabled the backup and now trying to delete the Recovery Services Vault, you will run into the following error.


Currently, you cannot use the Azure Portal to delete the backup item or even see it. You have to use PowerShell to get rid of it to be able to delete the Recovery Services Vault.

Have a look at the following PowerShell script.

$vault=Get-AzureRmRecoveryServicesVault -ResourceGroupName RecoveryServicesVault -Name backupstoragetest -Verbose
Set-AzureRmRecoveryServicesVaultContext -Vault $vault
$container=Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -BackupManagementType AzureSQL
$item=Get-AzureRmRecoveryServicesBackupItem -Container $container
Disable-AzureRmRecoveryServicesBackupProtection -Item $item -RemoveRecoveryPoints -Force -Verbose
Unregister-AzureRmRecoveryServicesBackupContainer -Container $container -Verbose
Remove-AzureRmRecoveryServicesVault -Vault $vault -Verbose

The PowerShell script will remove the backup item from the Recovery Services Vault, unregister the backup container and finally delete the Recovery Services Vault.



WordPress Cookie Notice by Real Cookie Banner