使用 REST API 更新 Azure 恢复服务保管库配置Update Azure Recovery Services Vault configurations using REST API

本文介绍如何使用 REST API 更新 Azure 恢复服务保管库中与备份相关的配置。This article describes how to update backup related configurations in Azure Recovery Services vault using REST API.

软删除状态Soft delete state

删除受保护项的备份是一项必须加以监视的重要操作。Deleting backups of a protected item is a significant operation that has to be monitored. 为防止意外删除,Azure 恢复服务保管库具有软删除功能。To protect against accidental deletions, Azure Recovery Services vault has a soft-delete capability. 此功能允许客户在删除后的某个时间段内还原已删除的备份(如有必要)。This capability allows customers to restore deleted backups, if necessary, within a time period after the deletion.

但某些情况下,不需要此功能。But there are scenarios in which this capability is not required. 如果保管库包含备份项(甚至是软删除的备份项),则无法删除 Azure 恢复服务保管库。An Azure Recovery Services vault cannot be deleted if there are backup items within it, even soft-deleted ones. 如果需要立即删除保管库,这可能会导致出现问题。This may pose a problem if the vault needs to be immediately deleted. 例如:部署操作通常会删除同一工作流中的已创建资源。For for example: deployment operations often clean up the created resources in the same workflow. 部署操作可以创建保管库,为项配置备份,执行测试还原,然后继续删除备份项和保管库。A deployment can create a vault, configure backups for an item, do a test restore and then proceed to delete the backup items and the vault. 如果保管库删除失败,则整个部署也可能会失败。If the vault deletion fails, the entire deployment might fail. 禁用软删除是确保立即删除的唯一方法。Disabling soft-delete is the only way to guarantee immediate deletion.

因此,你需要根据具体方案谨慎选择是否对特定保管库禁用软删除。So you need to carefully choose whether or not to disable soft-delete for a particular vault depending on the scenario. 有关详细信息,请参阅软删除一文。For more information, see the soft-delete article.

使用 REST API 获取软删除状态Fetch soft delete state using REST API

默认情况下,将为任何新建的恢复服务保管库启用软删除状态。By default, the soft-delete state will be enabled for any newly created Recovery Services vault. 若要获取/更新保管库的软删除状态,请查看与备份保管库的配置相关的 REST API 文档To fetch/update the state of soft-delete for a vault, use the backup vault's config related REST API document

若要获取保管库的当前软删除状态,请使用以下 GET 操作To fetch the current state of soft-delete for a vault, use the following GET operation

GET https://management.chinacloudapi.cn/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupconfig/vaultconfig?api-version=2019-05-13

GET URI 包含参数 {subscriptionId}{vaultName}{vaultresourceGroupName}The GET URI has {subscriptionId}, {vaultName}, {vaultresourceGroupName} parameters. 在本示例中,{vaultName} 是“testVault”,{vaultresourceGroupName} 是“testVaultRG”。In this example, {vaultName} is "testVault" and {vaultresourceGroupName} is "testVaultRG". 由于 URI 中给出了所有必需的参数,因此不需要单独的请求正文。As all the required parameters are given in the URI, there is no need for a separate request body.

GET https://management.chinacloudapi.cn/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testVaultRG/providers/Microsoft.RecoveryServices/vaults/testVault/backupconfig/vaultconfig?api-version=2019-05-13

响应Responses

GET 操作的成功响应如下所示:The successful response for the 'GET' operation is shown below:

名称Name 类型Type 说明Description
200 正常200 OK BackupResourceVaultConfigBackupResourceVaultConfig OKOK
示例响应Example response

提交 GET 请求后,将返回 200(成功)响应。Once the 'GET' request is submitted, a 200 (successful) response is returned.

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testvaultRG/providers/Microsoft.RecoveryServices/vaults/testvault/backupconfig/vaultconfig",
  "name": "vaultconfig",
  "type": "Microsoft.RecoveryServices/vaults/backupconfig",
  "properties": {
    "enhancedSecurityState": "Enabled",
    "softDeleteFeatureState": "Enabled"
  }
}

使用 REST API 更新软删除状态Update soft delete state using REST API

若要使用 REST API 更新恢复服务保管库的软删除状态,请使用以下 PATCH 操作To update the soft-delete state of the recovery services vault using REST API, use the following PATCH operation

PATCH https://management.chinacloudapi.cn/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/backupconfig/vaultconfig?api-version=2019-05-13

PATCH URI 包含参数 {subscriptionId}{vaultName}{vaultresourceGroupName}The PATCH URI has {subscriptionId}, {vaultName}, {vaultresourceGroupName} parameters. 在本示例中,{vaultName} 是“testVault”,{vaultresourceGroupName} 是“testVaultRG”。In this example, {vaultName} is "testVault" and {vaultresourceGroupName} is "testVaultRG". 如果将 URI 替换为上述值,则 URI 将如下所示。If we replace the URI with the values above, then the URI will look like this.

PATCH https://management.chinacloudapi.cn/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testVaultRG/providers/Microsoft.RecoveryServices/vaults/testVault/backupconfig/vaultconfig?api-version=2019-05-13

创建请求正文Create the request body

以下通用定义用于创建请求正文THe following common definitions are used to create a request body

有关详细信息,请参阅 REST API 文档For more details, refer to the REST API documentation

名称Name 必须Required 类型Type 说明Description
eTageTag StringString 可选的 eTagOptional eTag
locationlocation true StringString 资源位置Resource location
propertiesproperties VaultPropertiesVaultProperties 保管库的属性Properties of the vault
tagstags ObjectObject 资源标记Resource tags

示例请求正文Example request body

以下示例用于将软删除状态更新为“禁用”。The following example is used to update the soft-delete state to 'disabled'.

{
  "properties": {
    "enhancedSecurityState": "Enabled",
    "softDeleteFeatureState": "Disabled"
  }
}

响应Responses

PATCH 操作的成功响应如下所示:The successful response for the 'PATCH' operation is shown below:

名称Name 类型Type 说明Description
200 正常200 OK BackupResourceVaultConfigBackupResourceVaultConfig OKOK
示例响应Example response

提交 PATCH 请求后,将返回 200 (成功)响应。Once the 'PATCH' request is submitted, a 200 (successful) response is returned.

{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testvaultRG/providers/Microsoft.RecoveryServices/vaults/testvault/backupconfig/vaultconfig",
  "name": "vaultconfig",
  "type": "Microsoft.RecoveryServices/vaults/backupconfig",
  "properties": {
    "enhancedSecurityState": "Enabled",
    "softDeleteFeatureState": "Disabled"
  }
}

后续步骤Next steps

创建用于在此保管库中备份 Azure VM 的备份策略Create a backup policy for backing up an Azure VM in this vault.

有关 Azure REST API 的详细信息,请参阅以下文档:For more information on the Azure REST APIs, see the following documents: