-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[New Extension] Add chaos extension (Microsoft.Chaos 2026-05-01-preview) #9918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
necusjz
merged 13 commits into
Azure:main
from
kekivelez:users/kekivelez/chaos-codegen-20260604-020139-f228b86/cli-extension
Jun 26, 2026
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cfa816d
[Chaos] Initial codegen seed: spec @ f228b86c, package-2026-05-01-pre…
a6b2b0c
[Chaos] Shorten --scenario-configuration-name on chaos scenario confi…
bda2795
[Chaos] Refactor refresh-recommendation to AAZ-subclass + post_operat…
5c1cdf4
[Chaos] Remove flaky live_only integration tests in favor of unit + l…
92fb81c
[Chaos] Fix NoneType crash on refresh-recommendation success
63d2fc7
[Chaos] Fix NoneType crash on scenario config execute success
a265b87
[Chaos] Bump to 1.0.0b1 + compliant description per cli-extensions gu…
bbe9c2e
[Chaos] Address PR #9918 review: drop dead resource_group_name overri…
78ce25d
[Chaos] Regenerate aaz/_execute.py with correct command-path example
edd5817
Add `az chaos setup` porcelain command for first-day workspace boots…
de39211
remove -w
7a49b11
Address feedback: run lifecycle, flag consistency, table detail, help
8818d71
Added missing optional location parameter and updated service name to…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 1.0.0b1 | ||
| +++++++ | ||
| * Initial preview release of the ``chaos`` extension. Targets api-version | ||
| ``2026-05-01-preview`` of ``Microsoft.Chaos``. | ||
|
|
||
| Command surface: | ||
|
|
||
| * ``az chaos workspace`` -- ``create``, ``show``, ``list``, ``update``, | ||
| ``delete``, ``refresh-recommendation``, ``evaluate-scenarios``, | ||
| ``show-discovery``, ``show-evaluation``, ``identity`` subgroup. | ||
| * ``az chaos scenario`` -- ``create``, ``show``, ``list``, ``update``, | ||
| ``delete``. | ||
| * ``az chaos scenario config`` -- ``create``, ``show``, ``list``, | ||
| ``update``, ``delete``, ``validate``, ``fix-permissions``, ``execute``, | ||
| ``show-validation``, ``show-permission-fix``. | ||
| * ``az chaos scenario run`` -- ``start``, ``show``, ``list``, ``cancel``, | ||
| ``wait``. | ||
| * ``az chaos discovered-resource`` -- ``show``, ``list``. | ||
|
|
||
| Notable hand-written commands beyond the spec-derived surface: | ||
|
|
||
| * ``scenario run start`` (porcelain composite of validate + execute with | ||
| a satisfied evaluation gate). | ||
| * ``workspace refresh-recommendation`` / ``evaluate-scenarios`` -- | ||
| AAZ subclass override that adds inner-LRO failure detection | ||
| (``discoveries/latest`` + ``evaluations/latest`` ``properties.status`` | ||
| inspection) on top of the AAZ-generated outer-LRO polling. Surfaces | ||
| the silent-failure case (e.g. Azure Resource Graph propagation lag | ||
| after a fresh Reader role assignment) that the AAZ framework polling | ||
| alone misses. | ||
| * ``workspace show-discovery``, ``workspace show-evaluation``, | ||
| ``scenario config show-validation``, ``scenario config show-permission-fix`` | ||
| -- singleton-latest GETs not exposed by the spec. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Microsoft Azure CLI 'chaos' Extension | ||
|
|
||
| Azure CLI extension for Azure Chaos Studio v2 Workspaces. | ||
|
|
||
| Provides the `az chaos` command group for workspace lifecycle management, | ||
| scenario browsing, scenario configuration with validation and execution, | ||
| and run history with per-run cancellation. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| az extension add --name chaos | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| # Create a workspace with a system-assigned managed identity | ||
| az chaos workspace create -g MyRG --workspace-name my-workspace --location eastus \ | ||
| --system-assigned "" \ | ||
| --scopes "/subscriptions/<sub-id>/resourceGroups/MyRG" | ||
|
|
||
| # Create a workspace with a user-assigned managed identity | ||
| az chaos workspace create -g MyRG --workspace-name my-workspace --location eastus \ | ||
| --mi-user-assigned "/subscriptions/<sub-id>/resourceGroups/MyRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId" \ | ||
| --scopes "/subscriptions/<sub-id>/resourceGroups/MyRG" | ||
|
|
||
| # List workspaces | ||
| az chaos workspace list | ||
| az chaos workspace list -g MyRG | ||
|
|
||
| # List scenarios | ||
| az chaos scenario list -g MyRG --workspace-name my-workspace | ||
|
|
||
| # Create a scenario configuration (--scenario-id is auto-derived) | ||
| az chaos scenario config create -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 -n my-config \ | ||
| --parameters "[{key:duration,value:PT10M}]" \ | ||
| --filters "{locations:[westus2],zones:[1]}" | ||
|
|
||
| # Validate a scenario configuration | ||
| az chaos scenario config validate -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 -n my-config | ||
|
|
||
| # Fix resource permissions | ||
| az chaos scenario config fix-permissions -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 -n my-config | ||
|
|
||
| # Start a run | ||
| az chaos scenario run start -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 --config-name my-config | ||
|
|
||
| # Show run status | ||
| az chaos scenario run show -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 --run-id <id> | ||
|
|
||
| # List runs | ||
| az chaos scenario run list -g MyRG --workspace-name my-workspace \ | ||
| --scenario-name ZoneDown-1.0 | ||
| ``` | ||
|
|
||
| For full documentation, see the [Azure Chaos Studio CLI reference](https://learn.microsoft.com/azure/chaos-studio/). | ||
|
|
||
| ## Modifying the AAZ-generated code | ||
|
|
||
| **NEVER edit files under `azext_chaos/aaz/`.** They are generated by `aaz-dev` from | ||
| the pinned spec and overwritten on every regen. The regression test | ||
| `tests/latest/test_aaz_pristine.py` fails any PR that hand-edits `pre_operations` | ||
| or `post_operations` bodies inside `aaz/`. | ||
|
|
||
| To customize: | ||
|
|
||
| - **Arg aliases, command renames, help text, examples** → edit | ||
| `automation/cli-extension/scripts/customize_workspace.py` (the workspace | ||
| customization driver), then run | ||
| `automation/cli-extension/scripts/regen.cmd` to regenerate the | ||
| `azext_chaos/aaz/` tree. The pinned spec + commit SHA are recorded in | ||
| `automation/cli-extension/aaz-models/chaos/CODEGEN_SOURCE.md`. | ||
| - **`pre_operations` / `post_operations` hooks, computed args, derived defaults** | ||
| → subclass the generated class in `azext_chaos/custom.py` and register the | ||
| subclass in `azext_chaos/commands.py` via | ||
| `self.command_table["<full command name>"] = MySubclass(loader=self)`. | ||
| Existing examples: `ScenarioConfigCreate` (auto-derives `--scenario-id`). | ||
| - **New commands not in the spec** → write them in `azext_chaos/custom.py` | ||
| (regular Python functions wired with `g.custom_command(...)`) or, for full | ||
| AAZ-shaped commands, a sibling module like `azext_chaos/custom_wait.py` using | ||
| `@register_command` + an `AAZCommand` / `AAZWaitCommand` subclass that is | ||
| registered explicitly in `azext_chaos/commands.py`. | ||
|
|
||
| Reference: `Azure/azure-cli-extensions/src/connectedmachine/azext_connectedmachine` | ||
| is the canonical pattern for AAZ subclass + manual `command_table` registration. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure.cli.core import AzCommandsLoader | ||
| from azext_chaos._help import helps # pylint: disable=unused-import | ||
|
|
||
|
|
||
| class ChaosCommandsLoader(AzCommandsLoader): | ||
|
|
||
| def __init__(self, cli_ctx=None): | ||
| from azure.cli.core.commands import CliCommandType | ||
| chaos_custom = CliCommandType( | ||
| operations_tmpl='azext_chaos.custom#{}') | ||
| super().__init__(cli_ctx=cli_ctx, | ||
| custom_command_type=chaos_custom) | ||
|
|
||
| def load_command_table(self, args): | ||
| from azext_chaos.commands import load_command_table | ||
| from azure.cli.core.aaz import load_aaz_command_table | ||
| try: | ||
| from . import aaz | ||
| except ImportError: | ||
| aaz = None | ||
| if aaz: | ||
| load_aaz_command_table( | ||
| loader=self, | ||
| aaz_pkg_name=aaz.__name__, | ||
| args=args | ||
| ) | ||
| load_command_table(self, args) | ||
| return self.command_table | ||
|
|
||
| def load_arguments(self, command): | ||
| from azext_chaos._params import load_arguments | ||
| load_arguments(self, command) | ||
|
|
||
|
|
||
| COMMAND_LOADER_CLS = ChaosCommandsLoader |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.