Azure – Unable to delete an empty recovery vault

Recently I had an interesting issue with an Azure Recovery vault I was not able to delete with the error telling me there was still resources within the vault (see below).

Off course I have double or even triple check there was no resources still in the vault or still protected by the vault.

image_thumb-24

Vault cannot be deleted as there are existing resources within the vault. : <removed>. Please ensure all containers have been unregistered from the vault and all private endpoints associated with the vault have been deleted, and retry operation. For more details, see https://aka.ms/AB-AA4ecq5

After digging around and a support case, the solution was to run a bunch of PowerShell command from the Cloud Shell – don’t do it from your device with the Azure PowerShell module installed as the commands are not going to be recognized and you have to run the exact commands.

It ended to be related to some old SQL databases (meaning the workload type may change if you are facing the same issue)

Select-AzSubscription –Subscription <subscription where the vault is located>

$vault = Get-AzureRmRecoveryServicesVault –Name <name of the vault>

$vault

Set-AzureRmRecoveryServicesVaultContext -Vault $vault

$container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL

$container

$item = Get-AzureRmRecoveryServicesBackupItem -container $container -WorkloadType AzureSQLDatabase

$item

Disable-AzureRmRecoveryServicesBackupProtection -item $item[0] -RemoveRecoveryPoints -ea SilentlyContinue

you may have to repeat the above command by incrementing the $item value if you have more than 1 item returned fro the Get-AzureRmRecoveryServiceBackupItem commane

Unregister-AzureRmRecoveryServicesBackupContainer -Container $container

Remove-AzureRmRecoveryServicesVault -Vault $vault

Leave a Comment

Your email address will not be published. Required fields are marked *