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

Experiments - Create Or Update

创建或更新试验资源。

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Chaos/experiments/{experimentName}?api-version=2025-01-01

URI 参数

名称 必需 类型 说明
experimentName
path True

string

表示试验资源名称的字符串。

正则表达式模式: ^[^<>%&:?#/\\]+$

resourceGroupName
path True

string

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

subscriptionId
path True

string

uuid

目标订阅的 ID。 该值必须是 UUID。

api-version
query True

string

用于此作的 API 版本。

请求正文

名称 必需 类型 说明
location True

string

资源所在的地理位置

properties.selectors True ChaosTargetSelector[]:

选择器列表。

properties.steps True

ChaosExperimentStep[]

步骤列表。

identity

ManagedServiceIdentity

分配给此资源的托管服务标识。

tags

object

资源标记。

响应

名称 类型 说明
200 OK

Experiment

资源“试验”更新作成功

201 Created

Experiment

资源“试验”创建作成功

标头

  • Azure-AsyncOperation: string
  • Retry-After: integer
Other Status Codes

ErrorResponse

意外的错误响应。

安全性

azure_auth

Azure Active Directory OAuth2 Flow。

类型: oauth2
流向: implicit
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize

作用域

名称 说明
user_impersonation 模拟用户帐户

示例

Create/update a Experiment in a resource group.

示例请求

PUT https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment?api-version=2025-01-01

{
  "identity": {
    "type": "SystemAssigned"
  },
  "tags": {
    "key7131": "ryohwcoiccwsnewjigfmijz",
    "key2138": "fjaeecgnvqd"
  },
  "location": "eastus2euap",
  "properties": {
    "selectors": [
      {
        "type": "List",
        "id": "selector1",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          }
        ]
      }
    ],
    "steps": [
      {
        "name": "step1",
        "branches": [
          {
            "name": "branch1",
            "actions": [
              {
                "name": "urn:csci:microsoft:virtualMachine:shutdown/1.0",
                "type": "continuous",
                "duration": "PT10M",
                "parameters": [
                  {
                    "key": "abruptShutdown",
                    "value": "false"
                  }
                ],
                "selectorId": "selector1"
              }
            ]
          }
        ]
      }
    ]
  }
}

示例响应

Azure-AsyncOperation: https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/myResourceGroup/providers/Microsoft.Chaos/locations/eastus/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2024-11-01-preview
Location: https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/myResourceGroup/providers/Microsoft.Chaos/experiments/00000000-0000-0000-0000-000000000000?api-version=2024-11-01-preview
{
  "name": "exampleExperiment",
  "type": "Microsoft.Chaos/experiments",
  "id": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment",
  "identity": {
    "type": "SystemAssigned",
    "principalId": "d04ab567-2c07-43ef-a7f4-4527626b7f56",
    "tenantId": "8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"
  },
  "tags": {
    "key7131": "ryohwcoiccwsnewjigfmijz",
    "key2138": "fjaeecgnvqd"
  },
  "location": "eastus2euap",
  "properties": {
    "provisioningState": "Updating",
    "selectors": [
      {
        "type": "List",
        "id": "selector1",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          }
        ]
      }
    ],
    "steps": [
      {
        "name": "step1",
        "branches": [
          {
            "name": "branch1",
            "actions": [
              {
                "name": "urn:csci:microsoft:virtualMachine:shutdown/1.0",
                "type": "continuous",
                "duration": "PT10M",
                "parameters": [
                  {
                    "key": "abruptShutdown",
                    "value": "false"
                  }
                ],
                "selectorId": "selector1"
              }
            ]
          }
        ]
      }
    ]
  },
  "systemData": {
    "createdAt": "2021-07-01T00:00:00.0Z",
    "createdBy": "User",
    "createdByType": "b3a41dba-4415-4d36-9ee8-e5eaa86db976",
    "lastModifiedAt": "2021-07-01T00:00:00.0Z",
    "lastModifiedBy": "User",
    "lastModifiedByType": "b3a41dba-4415-4d36-9ee8-e5eaa86db976"
  }
}
Azure-AsyncOperation: https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/myResourceGroup/providers/Microsoft.Chaos/locations/eastus/operationStatus/00000000-0000-0000-0000-000000000000?api-version=2024-11-01-preview
Location: https://management.azure.com/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/myResourceGroup/providers/Microsoft.Chaos/experiments/00000000-0000-0000-0000-000000000000?api-version=2024-11-01-preview
{
  "name": "exampleExperiment",
  "type": "Microsoft.Chaos/experiments",
  "id": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Chaos/experiments/exampleExperiment",
  "identity": {
    "type": "SystemAssigned",
    "principalId": "d04ab567-2c07-43ef-a7f4-4527626b7f56",
    "tenantId": "8c3e2fb2-fe7a-4bf1-b779-d73990782fe6"
  },
  "tags": {
    "key7131": "ryohwcoiccwsnewjigfmijz",
    "key2138": "fjaeecgnvqd"
  },
  "location": "eastus2euap",
  "properties": {
    "provisioningState": "Creating",
    "selectors": [
      {
        "type": "List",
        "id": "selector1",
        "targets": [
          {
            "type": "ChaosTarget",
            "id": "/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine"
          }
        ]
      }
    ],
    "steps": [
      {
        "name": "step1",
        "branches": [
          {
            "name": "branch1",
            "actions": [
              {
                "name": "urn:csci:microsoft:virtualMachine:shutdown/1.0",
                "type": "continuous",
                "duration": "PT10M",
                "parameters": [
                  {
                    "key": "abruptShutdown",
                    "value": "false"
                  }
                ],
                "selectorId": "selector1"
              }
            ]
          }
        ]
      }
    ]
  },
  "systemData": {
    "createdAt": "2021-07-01T00:00:00.0Z",
    "createdBy": "User",
    "createdByType": "b3a41dba-4415-4d36-9ee8-e5eaa86db976",
    "lastModifiedAt": "2021-07-01T00:00:00.0Z",
    "lastModifiedBy": "User",
    "lastModifiedByType": "b3a41dba-4415-4d36-9ee8-e5eaa86db976"
  }
}

定义

名称 说明
ChaosExperimentBranch

表示步骤中的分支的模型。 每个试验总共 9 个。

ChaosExperimentStep

表示试验资源中的步骤的模型。

ChaosTargetListSelector

表示列表选择器的模型。

ChaosTargetQuerySelector

表示查询选择器的模型。

ChaosTargetSimpleFilter

表示简单目标筛选器的模型。

ChaosTargetSimpleFilterParameters

表示简单筛选器参数的模型。

ContinuousAction

表示连续作的模型。

createdByType

创建资源的标识的类型。

DelayAction

表示延迟作的模型。

DiscreteAction

表示离散作的模型。

ErrorAdditionalInfo

资源管理错误附加信息。

ErrorDetail

错误详细信息。

ErrorResponse

错误响应

Experiment

表示试验资源的模型。

ExperimentActionType

混沌试验作类型的枚举联合。

FilterType

区分筛选器类型的枚举。 目前仅支持 Simple 类型。

KeyValuePair

描述作设置的映射。

ManagedServiceIdentity

托管服务标识(系统分配和/或用户分配的标识)

ManagedServiceIdentityType

托管服务标识的类型(其中允许 SystemAssigned 和 UserAssigned 类型)。

ProvisioningState

给定 Azure 混沌资源的当前预配状态。

SelectorType

选择器类型的枚举。

systemData

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

TargetReference

表示对选择器中目标的引用的模型。

TargetReferenceType

目标引用类型的枚举。

UserAssignedIdentity

用户分配的标识属性

ChaosExperimentBranch

表示步骤中的分支的模型。 每个试验总共 9 个。

名称 类型 说明
actions ChaosExperimentAction[]:

作列表。

name

string

分支名称的字符串。

ChaosExperimentStep

表示试验资源中的步骤的模型。

名称 类型 说明
branches

ChaosExperimentBranch[]

分支列表。

name

string

步骤名称的字符串。

ChaosTargetListSelector

表示列表选择器的模型。

名称 类型 说明
filter ChaosTargetFilter:

ChaosTargetSimpleFilter

表示可应用于目标列表的可用筛选器类型的模型。

id

string

选择器 ID 的字符串。

targets

TargetReference[]

目标引用列表。

type string:

List

混沌目标选择器鉴别器类型

ChaosTargetQuerySelector

表示查询选择器的模型。

名称 类型 说明
filter ChaosTargetFilter:

ChaosTargetSimpleFilter

表示可应用于目标列表的可用筛选器类型的模型。

id

string

选择器 ID 的字符串。

queryString

string

针对目标资源的 Azure Resource Graph (ARG) 查询语言查询。

subscriptionIds

string[]

用于限定资源查询范围的订阅 ID 列表。

type string:

Query

混沌目标选择器鉴别器类型

ChaosTargetSimpleFilter

表示简单目标筛选器的模型。

名称 类型 说明
parameters

ChaosTargetSimpleFilterParameters

表示简单筛选器参数的模型。

type string:

Simple

混沌目标筛选器鉴别器类型

ChaosTargetSimpleFilterParameters

表示简单筛选器参数的模型。

名称 类型 说明
zones

string[]

要按其筛选目标的 Azure 可用性区域列表。

ContinuousAction

表示连续作的模型。

名称 类型 说明
duration

string

ISO8601表示持续时间的格式化字符串。

name

string

表示功能 URN 的字符串。

parameters

KeyValuePair[]

键值对列表。

selectorId

string

表示选择器的字符串。

type string:

continuous

混沌实验作鉴别器类型

createdByType

创建资源的标识的类型。

名称 类型 说明
Application

string

Key

string

ManagedIdentity

string

User

string

DelayAction

表示延迟作的模型。

名称 类型 说明
duration

string

ISO8601表示持续时间的格式化字符串。

name

string

表示功能 URN 的字符串。

type string:

delay

混沌实验作鉴别器类型

DiscreteAction

表示离散作的模型。

名称 类型 说明
name

string

表示功能 URN 的字符串。

parameters

KeyValuePair[]

键值对列表。

selectorId

string

表示选择器的字符串。

type string:

discrete

混沌实验作鉴别器类型

ErrorAdditionalInfo

资源管理错误附加信息。

名称 类型 说明
info

object

其他信息。

type

string

其他信息类型。

ErrorDetail

错误详细信息。

名称 类型 说明
additionalInfo

ErrorAdditionalInfo[]

错误附加信息。

code

string

错误代码。

details

ErrorDetail[]

错误详细信息。

message

string

错误消息。

target

string

错误目标。

ErrorResponse

错误响应

名称 类型 说明
error

ErrorDetail

错误对象。

Experiment

表示试验资源的模型。

名称 类型 说明
id

string

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

identity

ManagedServiceIdentity

分配给此资源的托管服务标识。

location

string

资源所在的地理位置

name

string

资源的名称

properties.provisioningState

ProvisioningState

给定试验资源的最新预配状态。

properties.selectors ChaosTargetSelector[]:

选择器列表。

properties.steps

ChaosExperimentStep[]

步骤列表。

systemData

systemData

包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。

tags

object

资源标记。

type

string

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

ExperimentActionType

混沌试验作类型的枚举联合。

名称 类型 说明
continuous

string

delay

string

discrete

string

FilterType

区分筛选器类型的枚举。 目前仅支持 Simple 类型。

名称 类型 说明
Simple

string

简单筛选器类型。

KeyValuePair

描述作设置的映射。

名称 类型 说明
key

string

作的设置的名称。

value

string

作设置的值。

ManagedServiceIdentity

托管服务标识(系统分配和/或用户分配的标识)

名称 类型 说明
principalId

string

系统分配标识的服务主体 ID。 此属性仅针对系统分配的标识提供。

tenantId

string

系统分配标识的租户 ID。 此属性仅针对系统分配的标识提供。

type

ManagedServiceIdentityType

托管服务标识的类型(其中允许 SystemAssigned 和 UserAssigned 类型)。

userAssignedIdentities

<string,  UserAssignedIdentity>

User-Assigned 标识
与资源关联的用户分配标识集。 userAssignedIdentities 字典密钥将为 ARM 资源 ID,格式为“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}”。 字典值可以是请求中的空对象({})。

ManagedServiceIdentityType

托管服务标识的类型(其中允许 SystemAssigned 和 UserAssigned 类型)。

名称 类型 说明
None

string

SystemAssigned

string

SystemAssigned,UserAssigned

string

UserAssigned

string

ProvisioningState

给定 Azure 混沌资源的当前预配状态。

名称 类型 说明
Canceled

string

资源创建已取消。

Creating

string

初始创建正在进行中。

Deleting

string

正在删除。

Failed

string

资源创建失败。

Succeeded

string

已创建资源。

Updating

string

正在进行更新。

SelectorType

选择器类型的枚举。

名称 类型 说明
List

string

列表选择器类型。

Query

string

查询选择器类型。

systemData

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

名称 类型 说明
createdAt

string

资源创建时间戳(UTC)。

createdBy

string

创建资源的标识。

createdByType

createdByType

创建资源的标识的类型。

lastModifiedAt

string

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

lastModifiedBy

string

上次修改资源的标识。

lastModifiedByType

createdByType

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

TargetReference

表示对选择器中目标的引用的模型。

名称 类型 说明
id

string

目标资源的资源 ID 的字符串。

type

TargetReferenceType

目标引用类型的枚举。

TargetReferenceType

目标引用类型的枚举。

名称 类型 说明
ChaosTarget

string

混沌目标引用类型。

UserAssignedIdentity

用户分配的标识属性

名称 类型 说明
clientId

string

分配的标识的客户端 ID。

principalId

string

已分配标识的主体 ID。