1
votes

Sorry For the Long Post:

I am attempting to clean up our Azure account and have a couple of old vaults that are not allowing me to delete them. I have tried a few things but am stuck with some of the responses I am getting from Powershell.

First attempted to delete the vault in the Azure portal and got the following message:

Vault cannot be deleted as there are existing resources within the vault. Please ensure there are no backup items, protected servers or backup management servers associated with this vault. Unregister the following containers associated with this vault before proceeding for deletion :

Did some looking around and Microsoft stated to delete the server from the vault. The server is still online, but the azure backup utility has no way of unregistering itself from the azure account that I could find. I am able to hit a delete button in the portal for the server, but after confirming to delete, it does nothing, and the object remains.

Looked for a PowerShell command and found another post on here:

https://serverfault.com/questions/838463/azure-recoveryservicevault-cant-be-removed/839848#839848

but the first few commands give back an error:

$vault = Get-AzureRmRecoveryServicesVault -Name "My Server Name"
Set-AzureRmRecoveryServicesVaultContext -Vault $vault

Set-AzureRmRecoveryServicesVaultContext : Cannot validate argument on parameter 'Vault'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At line:2 char:48 + Set-AzureRmRecoveryServicesVaultContext -Vault $vault + ~~~~~~ + CategoryInfo : InvalidData: (:) [Set-AzureRmRecoveryServicesVaultContext], ParameterBindingVa lidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.RecoveryServices.Bac kup.Cmdlets.SetAzureRmRecoveryServicesVaultContext

Another post on technet stated trying a different command if it was an older backup vault, which this is

$vault = Get-AzureRm​Recovery​Services​Backup​Container -Name "My Server Name"
Set-AzureRmRecoveryServicesVaultContext -Vault $vault

but, again I get an error:

Get-​Azure​Rm​Recovery​Services​Backup​Container : The term 'Get-​Azure​Rm​Recovery​Services​Backup​Container' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:10 + $vault = Get-​Azure​Rm​Recovery​Services​Backup​Container -Name "WDSE ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-​Azure​Rm​R...ackup​Container:String) [], CommandNotFound Exception + FullyQualifiedErrorId : CommandNotFoundException

I have no idea where to go from here and would be grateful for any suggestions.

this is the backup Items that I see in my Portal and options on what to do with them.

portal

Thank You

2

2 Answers

1
votes

Vault cannot be deleted as there are existing resources within the vault. Please ensure there are no backup items, protected servers or backup management servers associated with this vault. Unregister the following containers associated with this vault before proceeding for deletion :

You can find the existing resources within the vault following the steps below:

  1. Find your recovery service vault, go to Backup items, you will see the backup item count in your current vault. enter image description here
  2. Click the Azure Virtual Machine is backing up, then right click”…” to stop backup. enter image description here
  3. Once you finish stopping backup. You can refresh items and delete backup data.enter image description here

You can not delete the vault until there are currently no backup items in this vault. Hope it is helpful for you.

Update

Thanks for uploading the picture to clarify the issue. I suppose that you have a backup for D:\xxx on the local server through the Azure backup agent, and you want to delete the recovery service vault and related resources backup in this vault. If so, i will suggest doing the steps below:

  1. Uninstall the Azure Backup agent which binds the recovery service vault that you want to remove. Before this, you need to stop the scheduled backup and clean up the stored backups. More details about Uninstalling the Azure Backup agent
  2. With windows powershell, login your azure portal account using command Connect-AzureRmAccount, run the below commands to unregister backup containers. More details about commands here enter image description here

  3. Then go back to the azure portal, you should see no items in the backup items. Now you can delete the recovery service vault in azure portal.

-1
votes

We may have been dealing with the same problem. Here is how I solved it. Answer quoted below for reference.

I have not mapped this answer to the corresponding Azure commands, but I was able to find my way to a solution via the Azure Portal. The steps were as follows:

  1. Selected my Recovery Service resource
  2. Under the Manage section, clicked Backup Infrastructure
  3. Under Management Servers, clicked Protected Servers
  4. In the list that followed, clicked on the row where my Protected Server > Count was greater than 0, in my case, Azure Backup Agent (because the backup agent was installed on my Windows Desktop)
  5. Clicked on my server name in the Protected Server list
  6. Clicked Delete in the card for my protected server

After that completed, I was able to delete the entire vault. These steps may be helpful if you have other Backup Infrastructure resources and possibly even Site Recovery Infrastructure resources associated with a vault.

Update: It seems like there's an open issue for Get-AzureRmRecoveryServicesBackupItem not having any capacity to return MARS backup items which is ultimately what the issue here was.