使用 REST API 创建 Azure 恢复服务保管库Create Azure Recovery Services Vault using REST API

创建保管库 REST API 文档中概述了使用 REST API 创建 Azure 恢复服务保管库的步骤。The steps to create an Azure Recovery Services Vault using REST API are outlined in create vault REST API documentation. 让我们使用本文档作为参考在“中国东部”区域中创建一个名为“testVault”的保管库。Let us use this document as a reference to create a vault called "testVault" in "China East".

若要创建或更新 Azure 恢复服务保管库,请使用以下 PUT 操作。To create or update an Azure Recovery Services vault, use the following PUT operation.

PUT https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}?api-version=2016-06-01

创建请求Create a request

若要创建 PUT 请求,必须使用 {subscription-id} 参数。To create the PUT request, the {subscription-id} parameter is required. 如果拥有多个订阅,请参阅使用多个订阅If you have multiple subscriptions, see Working with multiple subscriptions. 你将定义资源的 {resourceGroupName}{vaultName} 以及 api-version 参数。You define a {resourceGroupName} and {vaultName} for your resources, along with the api-version parameter. 本文使用的是 api-version=2016-06-01This article uses api-version=2016-06-01.

以下标头是必需的:The following headers are required:

请求标头Request header 说明Description
Content-Type: Content-Type: 必需。Required. 设置为 application/jsonSet to application/json.
Authorization: Authorization: 必需。Required. 设置为有效的 Bearer 访问令牌Set to a valid Bearer access token.

有关如何创建请求的详细信息,请参阅 REST API 请求/响应的组件For more information about how to create the request, see Components of a REST API request/response.

创建请求正文Create the request body

下面的通用定义用来构建请求正文:The following common definitions are used to build a request body:

NameName 必须Required 类型Type 说明Description
eTageTag StringString 可选的 eTagOptional eTag
locationlocation true StringString 资源位置Resource location
propertiesproperties VaultPropertiesVaultProperties 保管库的属性Properties of the vault
skusku SkuSku 指明每个 Azure 资源的唯一系统标识符Identifies the unique system identifier for each Azure resource
标记tags ObjectObject 资源标记Resource tags

请注意,保管库名称和资源组名称是在 PUT URI 中提供的。Note that vault name and resource group name are provided in the PUT URI. 请求正文定义位置。The request body defines the location.

示例请求正文Example request body

以下示例正文用来在“中国东部”区域中创建一个保管库。The following example body is used to create a vault in "China East". 指定位置。Specify the location. SKU 始终为“Standard”。The SKU is always "Standard".

{
  "properties": {},
  "sku": {
    "name": "Standard"
  },
  "location": "China East"
}

响应Responses

对于要创建或更新恢复服务保管库的操作,有两个成功响应:There are two successful responses for the operation to create or update a Recovery Services vault:

NameName 类型Type 说明Description
200 正常200 OK 保管库Vault OKOK
201 Created201 Created 保管库Vault 已创建Created

有关 REST API 响应的详细信息,请参阅处理响应消息For more information about REST API responses, see Process the response message.

示例响应Example response

下面是前面的示例请求正文的精简后 201 Created 响应,该响应表明已分配了一个 id 并且 provisioningStateSucceededA condensed 201 Created response from the previous example request body shows an id has been assigned and the provisioningState is Succeeded:

{
  "location": "chinaeast",
  "name": "testVault",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "id": "/subscriptions/77777777-b0c6-47a2-b37c-d8e65a629c18/resourceGroups/Default-RecoveryServices-ResourceGroup/providers/Microsoft.RecoveryServices/vaults/testVault",
  "type": "Microsoft.RecoveryServices/vaults",
  "sku": {
    "name": "Standard"
  }
}

后续步骤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: