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

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

Benoit Hamet
Benoit Hamet
Benoit is working on Microsoft collaborative technologies He has been awarded as MVP for more than 12 years Currently MVP on Office 365 after being awarded on SharePoint (2011-2012) and Windows client & server (2002-2007) Speaker at various Microsoft events (TechDays, TechNet seminars) and Quest Software He works on on-premises (Active Directory, RADIUS/NPS, Exchange, Skype for Business, SharePoint, SQL, Terminal Server, Windows client and Windows Server) or online (Azure, Intune, Office 365, Exchange Online, SharePoint Online, Skype for Business Online, Teams) technologies