Azure RecoveryServiceVault can’t be removed

azurerecovery-services

During the free trial, I spent time fiddling and experimenting with azure. Now that we've moved to paid version, I need to delete all of the experimented things as we don't need all of them.

One of those is a Recovery services vault that somehow got something stuck in it's backup usage (see screenshot below)

The recovery vault as it is now, everything is empty apart from the GRS backup usage

I've looked in all the settings and can find nothing left to remove. Any storage account that may have been linked to the vault is long gone – it's really the only thing that is left in the resource group. I also can't remove the resource group because of this vault.

Any time I try to delete I get following error:

Vault deletion error

Vault 'TestRecoveryServiceVault' cannot be
deleted as there are existing resources within the vault. Please
delete any replicated items, registered servers, Hyper-V sites (Used
for Site Recovery), policy associations for System Center VMM clouds
(Used for Site Recovery) and then delete the vault.

I even tried the powershell commands

$vault = Get-AzureRmRecoveryServicesVault -Name "TestRecoveryServiceVault"
Remove-AzureRmRecoveryServicesVault -Vault $vault

(same error as above) and

Remove-AzureRmRecoveryServicesVault -Vault $vault -Force

(but this one throws an error that parameter -Force doesn't exist, I suspect outdated documentation)

I'm at my wits end and would really like this vault gone. Any help is appreciated.

Edit:

Clarification:

There are no tasks left in the vault; only 6MB of data that seems to have come from nowhere, as it didn't get deleted with the tasks. I did not opt to keep backup data when removing tasks.

Best Answer

Finally was able to remove the vault, after clearing the sql backups from it through powershell. I'm really surprised NO ONE knew about this and it took so much digging to find it.

commands for anyone else having this problem:

These commands are to first see if anything is in the database backups, then remove it all.

$vault = Get-AzureRmRecoveryServicesVault -Name "VaultName"

Set-AzureRmRecoveryServicesVaultContext -Vault $vault

VIEW THE BACKUP ITEMS

$container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $vault.Name

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

$availableBackups = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $item

$availableBackups      

REMOVE THE BACKUP ITEMS AND VAULT

$containers = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureSQL -FriendlyName $vault.Name

ForEach ($container in $containers)
{
    $items = Get-AzureRmRecoveryServicesBackupItem -container $container -WorkloadType AzureSQLDatabase

    ForEach ($item in $items)
    {
        Disable-AzureRmRecoveryServicesBackupProtection -item $item -RemoveRecoveryPoints -ea SilentlyContinue
    }

    Unregister-AzureRmRecoveryServicesBackupContainer -Container $container
}

Remove-AzureRmRecoveryServicesVault -Vault $vault

I hope I helped some other people out there who ran into this mess.

Related Topic