AGENT SKILL

创建 Chaos 工作区

create-workspace

预配 Microsoft.Chaos/workspaces 资源(v2),绑定托管标识,设置作用域,并在该作用域上授予 Reader RBAC 角色。

License 许可
MIT
最近更新
2026-10-28
Stars
★ 3
Forks
4

01 前言 Front Matter

name
create-workspace
description
Provision a Microsoft.Chaos/workspaces resource (v2), bind a managed identity, set scopes, and grant Reader RBAC on the scope.

02 资源文件 11

03 SKILL.md 正文

CreateWorkspace — Chaos Studio Workspace Provisioning

⛔ ABSOLUTE RULE: Do NOT improvise, skip, or substitute any step. On ANY error, STOP and wait for the user.

When to use this skill (vs. the MCP server)

This skill is the human-interactive path: it persists state to startchaos-state.json, renders cards, and produces the workspace + identity + Reader RBAC in one go. Use it when there is a user in the loop.

If you are an autonomous agent with no user to prompt, call chaos_create_workspace on the chaos-studio MCP server. Same provisioning + identity binding + Reader RBAC, returned as a single tool call. See mcp/README.md.

Both surfaces target Microsoft.Chaos 2026-05-01-preview and use the local az login session for auth.

How It Works

All provisioning logic lives in scripts/Invoke-CreateWorkspace.ps1. The script handles input validation, workspace creation via az chaos workspace create (the CLI awaits the provisioning LRO), identity resolution, RBAC test/grant, and state persistence.

The AI orchestrator's only job is:

  1. Set $env:STARTCHAOS_STATE_PATH to ${SESSION_DIR}/startchaos-state.json.
  2. Run the script with the required parameters.
  3. Handle exit codes that require user input (see below).
  4. Re-run with the user's answers as parameters.

Prerequisites

  • state.auth.status == "done" (run auth pre-flight first; the script refuses to start otherwise)
  • state.context.subscriptionId populated

Running the Script

$env:STARTCHAOS_STATE_PATH = "<session-dir>/startchaos-state.json"
& "<skill-dir>/scripts/Invoke-CreateWorkspace.ps1" `
    -ResourceGroup <rg> `
    -WorkspaceName <name> `
    -Scopes @('<arm-id>', ...) `
    [-Location <region>] `
    [-IdentityType SystemAssigned|UserAssigned] `
    [-UserAssignedIdentityResourceId <uami-arm-id>]

Idempotent: re-runs short-circuit when state.workspace.status == "done".

Exit Codes → AI Actions

Exit Meaning AI Action
0 Workspace ready Done — summary already rendered by script.
1 Hard error STOP. Render the error from script output. Wait for user. State has workspace.lastError.

If a required parameter is missing, PowerShell's parameter binder fails before the script body runs — gather the missing input via ask_user and retry.

Script Parameters

Parameter Required Default Description
-ResourceGroup yes — Azure resource group name
-WorkspaceName yes — Name for the workspace resource
-Scopes yes — ARM IDs the workspace is allowed to target (subscription / RG / service group)
-Location no westus2 Azure region
-IdentityType no SystemAssigned SystemAssigned or UserAssigned
-UserAssignedIdentityResourceId conditional — Required when -IdentityType UserAssigned

What the Script Handles (no AI logic needed)

  • Input validation and ARM-ID well-formedness checks
  • Workspace creation via az chaos workspace create (identity + scopes)
  • Provisioning LRO awaited by the CLI, with terminal-state surfacing
  • Identity resolution (SystemAssigned principalId from response; UserAssigned via UAMI GET)
  • Per-scope Test-CallerCanAssignRoles + Reader role assignment with remediation card on denial
  • Atomic state writes with error envelopes
  • Idempotent re-runs

Related Skills

  • start-chaos — orchestrator that invokes this skill
  • setup-scenario — next phase after workspace creation

04 同仓库更多 Skills

microsoft
microsoft/chaos-studio

混沌测试工作流编排

start-chaos

编排完整的 Chaos Studio v2 工作流:认证 → 工作区 → 场景 → 运行。共享单一状态文件并支持断点续跑。

SRE 工程师混沌工程与韧性测试
★ 3
microsoft
microsoft/chaos-studio

混沌场景搭建与配置

setup-scenario

发现推荐场景,构建并验证 ScenarioConfiguration,并自动修复资源权限。

SRE 工程师混沌工程与韧性测试
★ 3
microsoft
microsoft/chaos-studio

混沌场景执行与监控

run-scenario

执行 ScenarioConfiguration,并以流式方式输出 ScenarioRun 状态及各操作的细分进度,直至达到终止状态。

SRE 工程师混沌工程与韧性测试
★ 3
microsoft
microsoft/chaos-studio

混沌工程研究运行

chaos-study

为指导运行针对 Azure 工作区范围的 Chaos Studio 研究:与您一起构建稳定状态问题,动态发现 Chaos Studio 在该区域提供的操作,冻结计划,仅在您明确同意的情况下运行经过验证的场景配置,收集您选择的之前/期间/之后信号,并编写一份自包含的 HTML 报告供您审阅。当遇到'当 X 发生时我的服务会怎样?'或'我的服务能否抵御 X?'这类问题时,请从这里开始。

SRE 工程师实验设计与假设验证
★ 3
microsoft
microsoft/chaos-studio

混沌研究范围界定

chaos-study-scope

在运行任何操作之前构建 Chaos(混沌)研究框架:解析或创建 Chaos Studio V2 工作区,读取服务在其范围内发现的资源,动态发现该区域中可用的操作和场景,表达一个可证伪的稳定状态谓词,验证该操作是否符合范围内的内容,然后冻结并对研究计划进行哈希处理。

SRE 工程师实验设计与假设验证
★ 3
microsoft
microsoft/chaos-studio

Chaos 研究计划执行

chaos-study-run

使用 Chaos Studio V2 针对 Azure 执行已冻结的 Chaos 研究计划:验证计划完整性、创建并验证场景配置、要求显式输入同意短语、收集基线证据、执行场景运行、收集运行期间及恢复后的证据,并始终清理配置。默认为试运行(dry-run)。

SRE 工程师测试与质量保障
★ 3