While working on Azure Portal Get Azure virtual machine backup reports using Powershell I was trying to decommision few Azure Recovery Service Vault (Backup) resource by deleteing it, I went to Azure portal selected Recovery Service Vault from Resource Group and pressed delete button, but I was receiving below errors.
Executed delete command on 1 selected items Succeeded: 0, Failed: 1, Canceled: 0. Error details vault828: Recovery Services vault cannot be deleted as there are backup items in soft deleted state in the vault. The soft deleted items are permanently deleted after 14 days of delete operation. Please try vault deletion after the backup items are permanently deleted and there is no item in soft deleted state left in the vault.For more information, refer https://aka.ms/SoftDeleteCloudWorkloads. The registered items are : vcloud-lab-vm01 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 (Code: ServiceResourceNotEmptyWithBackendMessage) Executed delete command on 15 selected items Succeeded: 14, Failed: 1, Canceled: 0. Error details vault828: Vault cannot be deleted as there are existing resources within the vault. : vcloud-lab-vm01 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 (Code: ServiceResourceNotEmptyWithBackendMessage)
I clicked on Recovery Services Vault and checked Backup items from right side navigation pane. I found there is a Backup Item exist with backup management type of Azure Virtual Machine, Before attempting deleting vault All backup Item count should be 0 or there shouldn't be backup in soft delete which I will discuss later in this article.
I clicked on the backup item, selected Virtual Machine name, on the 3 vertical dots, clicked delete backup data.
Next I received option either to retain or delete backup data. Selected Delete backup data, this option will stop all scheduled backup job and delete backup data. Validation successful after clicking Delete button.
Now Tried to delete Recovery Services Vault again, but I was receiving same error again. Root cause - This happens due to backup data will be deleted permanently after 14 days, it is protected under soft delete feature. Now I dont want to wait for that much time and delete it instantly.
To resolve the issue I went to Virtual Machine Backup Item clicked on 3 vertical dots and Undelete it from context menu.
All restore points for this backup item will be undeleted and the item will come to 'Stop protection will retain data' state. You can 'Resume Backup' to continue the scheduled backupoperations as per the selected policy. Note: Garbage Collection will start with resume backup operation and all the expired restore points will be cleaned.
This shows the days left until permanant deletion, Click Undelete button.
Go to Recover Services Vault Properties from left pane. Click Security Settings Update. On the Disable Soft Delete feature. This Soft delete feature is only available for eligible backup management types. Soft delete protects backup data from accidental deletes. Once you disable it, All Future deletes will be instant and will not have soft delete protection this action will not impact items already in soft deleted state.
Now try deleting backup data again, go to Backup Items Azure Virtual Machine, Click Delete backup data.
Select the name of Backup Item and click Delete button. Validation is successful.
Now under Backup Items there are 0 Bakcup item count.
In the last click Delete button on Recovery Services Vault or from select vault on Resource group.
This is a confirmation dialog box, Make sure you want to delete Recovery Services Vault name, Click Yes button.
This time Recovery Services vault successfully deleted without any error.
Useful Information
Create an Azure App registrations in Azure Active Directory using PowerShell & AzureCLI
Get started and configure with certificate-based authentication in Azure
Create a Virtual machine on Microsoft Azure
PowerShell List All Azure Resverations
Powershell get the list of Azure Reservations Virtual Machines instances
Get the list Azure Reservation Catalog with PowerShell and AzureCLI
Azure automation account DSC for On-Premise Virtual Machine on boarding
Azure Powershell : Operation returned an invalid status code 'BadRequest'
Get Azure virtual machine backup reports using Powershell