Share via


ASR and Azure Backup: How to force or automate deletion of a Site Recovery Vault


The preferred method to delete a recovery vault is using this process:

 

/en-us/azure/site-recovery/site-recovery-manage-registration-and-protection

 

In some cases, there may be orphaned items that are difficult to detect or other issues that cause manual deletion fail. Use the following steps to completely delete a vault (even when protected items are present):

 

 Try this first in an elevated PowerShell window:

  1. Login-AzureRmAccount
  2.  Follow the prompts to log in to your Azure account
  3. This will display your SubscriptionName for use in step 2
  4. Select-AzureRmSubscription -SubscriptionName "YourSubName"
  5. You can also specify your subscriptionID or TenantID if needed
  6. $vault = Get-AzureRmSiteRecoveryVault -Name "vaultname"
  7. Remove-AzureRmSiteRecoveryVault -Vault $vault

If this does not work, use these steps.  ARMClient here will bypass any restrictions and delete all items in the vault, along with the vault.  Use this with caution, and make sure you have backed up anything important beforehand, as we cannot undelete anything after the fact

The below procedure will work if Site recovery vault is configured in the ARM portal  (https://portal.azure.com). If you are using the classic portal (https://manage.windowsazure.com), you will have to find the resource group of this vault in portal.azure.com and delete the Resource group. Please check that the resource group contains only the ‘site recovery vault’ in it and no other resources like storage account etc.

 

  1. Open an elevated PowerShell window and execute the command below.  This will download the ARM Client package to execute Azure APIs which we will use to force deletion of the vault:

 

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

 

  1. Install the ARM Client using the command:

  choco.exe install armclient

 

  1. To see the details of vault that you are trying to delete, execute the below in an elevated PowerShell window to fetch the details of the vault so you can ensure you are deleting the intended Recovery services vault
    1. Syntax:
      1. C:\ProgramData\chocolatey\lib\ARMClient\tools\ARMClient.exe get /subscriptions/<Subscription ID>/resourceGroups/<Resource Group Name>/providers/Microsoft.RecoveryServices/vaults/<Recovery services Vault Name>?api-version=2015-03-15
    2. Example:
      1. "C:\ProgramData\chocolatey\lib\ARMClient\tools\ARMClient.exe" get /subscriptions/423425-2222-aaaa-dddd-a4f2d72576df/resourceGroups/yourresourcegroup/providers/Microsoft.RecoveryServices/vaults/yourusername?api-version=2015-03-15

{

  "location": "westus",

  "name": "yourusername",

  "etag": "W/\datetime'2016-09-01T02%3A21%3A09.965917Z'\",

  "properties": {

    "provisioningState": "Succeeded"

  },

  "id": "/subscriptions/423425-2222-aaaa-dddd-a4f2d72576df/resourceGroups/yourresourcegroup/providers/Microsoft.RecoveryServices/vaults/yourusername",

  "type": "Microsoft.RecoveryServices/vaults",

  "sku": {

    "name": "RS0",

    "tier": "Standard"

  }

}

 

  1. Once you have confirmed the vault details, execute this command to delete the vault
    1. Syntax:
      1. "C:\ProgramData\chocolatey\lib\ARMClient\tools\ARMClient.exe" delete /subscriptions/<Subscription ID>/resourceGroups/<Resource Group Name>/providers/Microsoft.RecoveryServices/vaults/<Recovery services Vault Name>?api-version=2015-03-15
    2. Example:
      1. "C:\ProgramData\chocolatey\lib\ARMClient\tools\ARMClient.exe" delete /subscriptions/423425-2222-aaaa-dddd-a4f2d72576df/resourceGroups/yourresourcegroup/providers/Microsoft.RecoveryServices/vaults/yourusername?api-version=2015-03-15
  2. Log in to the Azure portal and verify that the vault is deleted.

Warning:  This command will delete all content and should only be used if you are absolutely sure you want to delete your recovery vault.  There is no way to recover deleted items after you have deleted the vault.