你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Resource Sync Rules - Create Or Update

在父自定义位置、订阅 ID 和资源组中创建或更新资源同步规则

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}?api-version=2021-08-31-preview

URI 参数

名称 必需 类型 说明
childResourceName
path True

string

资源同步规则名称。

Regex pattern: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$

resourceGroupName
path True

string

资源组的名称。 此名称不区分大小写。

resourceName
path True

string

自定义位置名称。

Regex pattern: ^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$

subscriptionId
path True

string

目标订阅的 ID。

api-version
query True

string

要用于此操作的 API 版本。

请求正文

名称 必需 类型 说明
location True

string

资源所在的地理位置

properties.priority

integer

优先级表示资源同步规则的优先级

properties.selector

Selector

标签选择器由两个部分组成:matchLabels 和 matchExpressions。 第一部分 matchLabels 是 {key,value} 对的映射。 matchLabels 映射中的单个 {key,value} 等效于 matchExpressions 的元素,其键字段为“key”,运算符为“In”,值数组仅包含“value”。 第二部分 matchExpressions 是资源选择器要求的列表。 有效运算符包括 In、NotIn、Exists 和 DoesNotExist。 对于 In 和 NotIn,设置的值必须为非空。 如果为 Exists 和 DoesNotExist,则设置的值必须为空。 必须满足 matchLabels 和 matchExpressions 中的所有要求才能匹配。

properties.targetResourceGroup

string

对于未映射的自定义资源,其标签将用于查找匹配的资源同步规则。 如果此资源同步规则是具有最高优先级的匹配规则之一,则将未映射的自定义资源投影到与此资源同步规则关联的目标资源组。 创建此资源同步规则的用户应对目标资源组具有写入权限,创建资源同步规则时将验证此写入权限。

tags

object

资源标记。

响应

名称 类型 说明
200 OK

resourceSyncRule

确定

201 Created

resourceSyncRule

创建

Other Status Codes

ErrorResponse

描述操作失败原因的错误响应。

安全性

azure_auth

Azure Active Directory OAuth2 流

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

名称 说明
user_impersonation 模拟用户帐户

示例

Create/Update Resource Sync Rule

Sample Request

PUT https://management.azure.com/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourceSyncRules/resourceSyncRule01?api-version=2021-08-31-preview

{
  "location": "West US",
  "properties": {
    "targetResourceGroup": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup",
    "priority": 999,
    "selector": {
      "matchLabels": {
        "key1": "value1"
      },
      "matchExpressions": [
        {
          "key": "key4",
          "operator": "In",
          "values": [
            "value4"
          ]
        }
      ]
    }
  }
}

Sample Response

{
  "id": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules/resourceSyncRule01",
  "name": "resourceSyncRule01",
  "location": "West US",
  "type": "Microsoft.ExtendedLocation/customLocations/resourceSyncRules",
  "systemData": {
    "createdBy": "string",
    "createdByType": "Application",
    "createdAt": "2021-07-15T18:53:29.0928001Z",
    "lastModifiedBy": "string",
    "lastModifiedByType": "Application",
    "lastModifiedAt": "2021-07-15T18:53:29.0928001Z"
  },
  "properties": {
    "provisioningState": "Succeeded",
    "targetResourceGroup": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup",
    "priority": 999,
    "selector": {
      "matchLabels": {
        "key1": "value1"
      },
      "matchExpressions": [
        {
          "key": "key4",
          "operator": "In",
          "values": [
            "value4"
          ]
        }
      ]
    }
  }
}
{
  "id": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ExtendedLocation/customLocations/customLocation01/resourcesyncrules/resourceSyncRule01",
  "name": "resourceSyncRule01",
  "location": "West US",
  "type": "Microsoft.ExtendedLocation/customLocations/resourceSyncRules",
  "systemData": {
    "createdBy": "string",
    "createdByType": "Application",
    "createdAt": "2021-07-16T18:53:29.0928001Z",
    "lastModifiedBy": "string",
    "lastModifiedByType": "Application",
    "lastModifiedAt": "2021-07-16T18:53:29.0928001Z"
  },
  "properties": {
    "provisioningState": "Creating",
    "targetResourceGroup": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup",
    "priority": 999,
    "selector": {
      "matchLabels": {
        "key1": "value1"
      },
      "matchExpressions": [
        {
          "key": "key4",
          "operator": "In",
          "values": [
            "value4"
          ]
        }
      ]
    }
  }
}

定义

名称 说明
createdByType

创建资源的标识类型。

ErrorAdditionalInfo

资源管理错误附加信息。

ErrorDetail

错误详细信息。

ErrorResponse

错误响应

resourceSyncRule

资源同步规则定义。

Selector

标签选择器由两个部分组成:matchLabels 和 matchExpressions。 第一部分 matchLabels 是 {key,value} 对的映射。 matchLabels 映射中的单个 {key,value} 等效于 matchExpressions 的元素,其键字段为“key”,运算符为“In”,值数组仅包含“value”。 第二部分 matchExpressions 是资源选择器要求的列表。 有效运算符包括 In、NotIn、Exists 和 DoesNotExist。 对于 In 和 NotIn,设置的值必须为非空。 如果为 Exists 和 DoesNotExist,则设置的值必须为空。 必须满足 matchLabels 和 matchExpressions 中的所有要求才能匹配。

systemData

与资源的创建和上次修改相关的元数据。

createdByType

创建资源的标识类型。

名称 类型 说明
Application

string

Key

string

ManagedIdentity

string

User

string

ErrorAdditionalInfo

资源管理错误附加信息。

名称 类型 说明
info

object

其他信息。

type

string

其他信息类型。

ErrorDetail

错误详细信息。

名称 类型 说明
additionalInfo

ErrorAdditionalInfo[]

错误附加信息。

code

string

错误代码。

details

ErrorDetail[]

错误详细信息。

message

string

错误消息。

target

string

错误目标。

ErrorResponse

错误响应

名称 类型 说明
error

ErrorDetail

错误对象。

resourceSyncRule

资源同步规则定义。

名称 类型 说明
id

string

资源的完全限定的资源 ID。 例如 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}

location

string

资源所在的地理位置

name

string

资源的名称

properties.priority

integer

优先级表示资源同步规则的优先级

properties.provisioningState

string

资源同步规则的预配状态。

properties.selector

Selector

标签选择器由两个部分组成:matchLabels 和 matchExpressions。 第一部分 matchLabels 是 {key,value} 对的映射。 matchLabels 映射中的单个 {key,value} 等效于 matchExpressions 的元素,其键字段为“key”,运算符为“In”,值数组仅包含“value”。 第二部分 matchExpressions 是资源选择器要求的列表。 有效运算符包括 In、NotIn、Exists 和 DoesNotExist。 对于 In 和 NotIn,设置的值必须为非空。 如果为 Exists 和 DoesNotExist,则设置的值必须为空。 必须满足 matchLabels 和 matchExpressions 中的所有要求才能匹配。

properties.targetResourceGroup

string

对于未映射的自定义资源,其标签将用于查找匹配的资源同步规则。 如果此资源同步规则是具有最高优先级的匹配规则之一,则将未映射的自定义资源投影到与此资源同步规则关联的目标资源组。 创建此资源同步规则的用户应对目标资源组具有写入权限,创建资源同步规则时将验证此写入权限。

systemData

systemData

与资源的创建和上次修改相关的元数据

tags

object

资源标记。

type

string

资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”

Selector

标签选择器由两个部分组成:matchLabels 和 matchExpressions。 第一部分 matchLabels 是 {key,value} 对的映射。 matchLabels 映射中的单个 {key,value} 等效于 matchExpressions 的元素,其键字段为“key”,运算符为“In”,值数组仅包含“value”。 第二部分 matchExpressions 是资源选择器要求的列表。 有效运算符包括 In、NotIn、Exists 和 DoesNotExist。 对于 In 和 NotIn,设置的值必须为非空。 如果为 Exists 和 DoesNotExist,则设置的值必须为空。 必须满足 matchLabels 和 matchExpressions 中的所有要求才能匹配。

名称 类型 说明
matchExpressions.key

string

键是选择器应用于的标签键。

matchExpressions.operator

string

运算符字段表示键与一组值的关系。 有效运算符为 In、NotIn、Exists 和 DoesNotExist。

matchExpressions.values

string[]

标签值

matchLabels

object

MatchLabels 是 {key,value} 对的映射。 matchLabels 映射中的单个 {key,value} 等效于 matchExpressions 的元素,其键字段为“key”,运算符为“In”,值数组仅包含“value”。

systemData

与资源的创建和上次修改相关的元数据。

名称 类型 说明
createdAt

string

资源创建时间戳 (UTC) 。

createdBy

string

创建资源的标识。

createdByType

createdByType

创建资源的标识类型。

lastModifiedAt

string

资源上次修改的时间戳 (UTC)

lastModifiedBy

string

上次修改资源的标识。

lastModifiedByType

createdByType

上次修改资源的标识类型。