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

快速入门:使用 Azure Chaos Studio 创建并运行混沌试验

开始使用 Azure Chaos Studio,通过使用虚拟机 (VM) 关闭直接服务试验来使服务更适应实际情形中的故障。

先决条件

注册 Chaos Studio 资源提供程序

如果你是第一次使用 Chaos Studio,那么在加入资源和创建试验之前,必须先注册 Chaos Studio 资源提供程序。 对于使用 Chaos Studio 的每个订阅,必须执行以下步骤:

  1. 打开 Azure 门户
  2. 搜索“订阅”,然后打开“订阅管理”页。
  3. 选择要在其中使用 Chaos Studio 的订阅。
  4. 在左侧窗格中,选择“资源提供程序”。
  5. 在显示的资源提供程序列表中,搜索“Microsoft.Chaos”。
  6. 选择 Microsoft.Chaos 提供程序,然后选择“注册”按钮。

创建 Chaos Studio 支持的 Azure 资源

创建一个 Azure 资源,并确保它是受支持的故障提供程序之一。 此外,验证此资源是否在 Chaos Studio 可用的区域创建。 在此试验中,我们选择一个 Azure VM,它是 Chaos Studio 支持的故障提供程序之一。

在创建的 VM 上启用 Chaos Studio

  1. 打开 Azure 门户

  2. 在搜索栏中搜索“Chaos Studio”

  3. 选择“目标”,然后转到创建的 VM。

  4. 选中 VM 旁边的复选框。 从下拉菜单中选择“启用目标”>“启用直接服务目标”。

    Screenshot that shows the Targets view in the Azure portal.

  5. 确认列出了所需的资源。 选择“查看 + 启用”,然后选择“启用”

  6. 此时会显示一条通知,指示已成功启用所选资源。

    Screenshot that shows a notification that indicates that targets were successfully enabled.

创建试验

  1. 选择“试验”。

    Screenshot that shows selecting Experiments.

  2. 选择“创建”>“新建试验”。

  3. 填写要在其中部署混沌试验的“订阅”、“资源组”和“位置”框。 为试验指定一个名称。 选择“下一步: 试验设计器”。

    Screenshot that shows adding experiment basics.

  4. 在 Chaos Studio 试验设计器中,为“步骤”和“分支”指定一个易记名称。 再次选择“添加操作”>“添加错误”。

    Screenshot that shows the Experiment designer.

  5. 从下拉列表中选择“VM 关闭”。 然后在“持续时间”框中填写你希望故障持续的分钟数。

    Screenshot that shows Fault properties.

  6. 选择“下一步: 目标资源”。

    Screenshot that shows adding a target.

  7. 选择添加

    Screenshot that shows the Add button.

  8. 验证试验是否正确,然后选择“查看 + 创建”>“创建”。

    Screenshot that shows creating the experiment.

向 VM 授予实验权限

  1. 转到 VM 并选择“访问控制(IAM)”。

    Screenshot that shows Access control (IAM) in the left pane.

  2. 选择添加

    Screenshot that shows Add.

  3. 选择“添加角色分配”。

    Screenshot that shows the Add role assignment button.

  4. 搜索“虚拟机参与者”并选择角色。 选择下一步

    Screenshot that shows choosing the role for the VM.

  5. 选择“托管标识”选项

  6. 选择“选择成员”,然后搜索试验名称。 选择试验,然后选择“选择”。

    Screenshot that shows selecting the experiment.

  7. 选择“查看 + 分配”。

运行混沌试验

  1. 打开 Azure 门户:

    • 如果你使用的是 @microsoft.com 帐户,请转到此网站
    • 如果你使用的外部帐户,请转到此网站
  2. 选中试验名称旁边的复选框,然后选择“启动试验”。

    Screenshot that shows the Start experiment button.

  3. 选择“是”,确认要启动混沌试验。

    Screenshot that shows confirming you want to start an experiment.

  4. (可选)选择试验名称,查看试验执行状态的详细视图。

清理资源

  1. 选中试验名称旁边的复选框,然后选择“删除”。

    Screenshot that shows selecting the experiment to delete.

  2. 选择“是”以确认要删除该试验。

  3. 在 Azure 门户搜索栏中搜索创建的 VM。

    Screenshot that shows selecting the VM.

  4. 选择“删除”,避免为该资源付费。

    Screenshot that shows deleting the VM.

后续步骤

运行 VM 关闭直接服务试验后,接下来可以执行以下操作: