-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Henrydai/implement changesafety crud for 2026-01-01-preview after changeRecord renaming #9357
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
notyashhh
merged 30 commits into
Azure:main
from
henryzdai:henrydai/implementChangeStateCRUD0901
Apr 24, 2026
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e64478d
Add stub code
78206ad
Fix parsing
3cfd921
Fix parsing
d83dcb8
Fix displaying
ab84a4e
Fix commands
c23e29e
Add tests
4cbcc1a
Fix style
2c84429
Rename cli extension module name
6224b85
Fix linter
d61c5b9
Fix linter
094fec2
Fix linter
2369dba
Fix module name
68fcc8a
add test scenarios
744096e
Fix style
e1203e6
Add service name
a547256
Add stageprogression and stagemap
1382964
Update alias
125fc1d
Update ChangeRecord name
14d0515
Address comments
73574fa
Update comments
e772379
Update CLI to rename changeRecords for 2026-01-01-repview
e174cb9
Update CLI to rename changeRecords for 2026-01-01-repview
f6c9c15
Fix custom
6ef97f0
Fix issues
37d525c
fix stageMap parameters
3d1d8c0
Update changesafety docs, help text, and test recording
af870d3
Address PR review: add stageprogression help docs, stagevariables exa…
5a1b91a
Fix VCR cassette host: replace eastus2euap with management.azure.com
3b93a8e
Fix CI test failures: subscription_id resolution and target normaliza…
9d2df8c
Address PR review: deduplicate code, fix dual-fire bug, clean up help…
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,13 @@ | ||
| .. :changelog: | ||
|
|
||
| Release History | ||
| =============== | ||
|
|
||
| 1.0.0b1 | ||
| +++++++ | ||
| * Initial release. | ||
| * Manage ChangeRecord, StageMap, and StageProgression resources (API version ``2026-01-01-preview``). | ||
| * Custom ``--targets`` parsing with key=value shorthand (e.g., ``resourceId=...,operation=DELETE``). | ||
| * ``--stagemap-name`` shortcut to reference a StageMap by name. | ||
| * Default scheduling: ``anticipatedStartTime`` defaults to now, ``anticipatedEndTime`` to +8 hours. | ||
| * Supports ``--acquire-policy-token`` and ``--change-reference`` for guarded resource operations. |
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,117 @@ | ||
| # Azure CLI Change Safety Extension | ||
| Azure CLI extension for managing Change Safety resources. This includes `ChangeRecord`, `StageMap`, and `StageProgression` resources for coordinating, tracking, and safely deploying changes across your Azure environment. | ||
|
|
||
| ## Installation | ||
| ```bash | ||
| az extension add --source <path-to-extension-dist> --yes | ||
| # or install the latest published build | ||
| az extension add --name azure-changesafety | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ### ChangeRecord | ||
| ```bash | ||
| az changesafety changerecord create # Create a ChangeRecord for one or more targets. | ||
| az changesafety changerecord update # Update metadata, rollout settings, or scheduling. | ||
| az changesafety changerecord delete # Delete a ChangeRecord resource. | ||
| az changesafety changerecord show # Display details for a ChangeRecord resource. | ||
| az changesafety changerecord list # List ChangeRecord resources. | ||
| ``` | ||
|
|
||
| ### StageMap | ||
| ```bash | ||
| az changesafety stagemap create # Create a StageMap defining rollout stages. | ||
| az changesafety stagemap update # Update StageMap stages. | ||
| az changesafety stagemap delete # Delete a StageMap resource. | ||
| az changesafety stagemap show # Display details for a StageMap resource. | ||
| az changesafety stagemap list # List StageMap resources. | ||
| ``` | ||
|
|
||
| ### StageProgression | ||
| ```bash | ||
| az changesafety stageprogression create # Create a StageProgression to track stage execution. | ||
| az changesafety stageprogression update # Update StageProgression status or comments. | ||
| az changesafety stageprogression delete # Delete a StageProgression resource. | ||
| az changesafety stageprogression show # Display details for a StageProgression resource. | ||
| az changesafety stageprogression list # List StageProgression resources for a ChangeRecord. | ||
| ``` | ||
|
|
||
| Run `az changesafety -h` to see full command groups and examples. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### StageMap Examples | ||
| Create a two-stage StageMap for rollout: | ||
| ```bash | ||
| az changesafety stagemap create \ | ||
| --stage-map-name rolloutStageMap \ | ||
| --stages "[{name:Canary,sequence:1},{name:Production,sequence:2}]" | ||
| ``` | ||
|
|
||
| Create a StageMap with configurable parameters: | ||
| ```bash | ||
| # Parameters use AAZ shorthand: paramName.{string|number|array|object}.property=value | ||
| # Use --parameters paramName.string="??" to explore available properties | ||
| az changesafety stagemap create \ | ||
| --stage-map-name parameterized-rollout \ | ||
| --stages "[{name:Canary,sequence:1},{name:Production,sequence:2}]" \ | ||
| --parameters region.string.default-value=westus batchSize.number.default-value=10 | ||
| ``` | ||
|
|
||
| ### ChangeRecord Examples | ||
| Create a ChangeRecord for a manual touch operation (e.g., delete a Traffic Manager profile): | ||
| ```bash | ||
|
henryzdai marked this conversation as resolved.
|
||
| az changesafety changerecord create \ | ||
| -g MyResourceGroup \ | ||
| -n delete-trafficmanager \ | ||
| --change-type ManualTouch \ | ||
| --rollout-type Hotfix \ | ||
| --targets "resourceId=/subscriptions/<subId>/resourceGroups/MyResourceGroup/providers/Microsoft.Network/trafficManagerProfiles/myProfile,operation=DELETE" \ | ||
| --description "Delete Traffic Manager profile for maintenance" | ||
| ``` | ||
|
|
||
| Create a ChangeRecord for an app deployment with a StageMap reference: | ||
| ```bash | ||
|
henryzdai marked this conversation as resolved.
|
||
| az changesafety changerecord create \ | ||
| -g MyResourceGroup \ | ||
| -n changerecord-webapp-rollout \ | ||
| --change-type AppDeployment \ | ||
| --rollout-type Normal \ | ||
| --targets "resourceId=/subscriptions/<subId>/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/myApp,operation=PUT" \ | ||
| --stagemap-name rolloutStageMap \ | ||
| --links name=Runbook uri=https://contoso.com/runbook | ||
| ``` | ||
|
|
||
| > **Scope:** When `-g` is omitted, the ChangeRecord is created at subscription scope. Use `-g` to scope it to a specific resource group. | ||
|
|
||
| Update the ChangeRecord and add a comment: | ||
| ```bash | ||
| az changesafety changerecord update \ | ||
| -g MyResourceGroup \ | ||
| -n changerecord-webapp-rollout \ | ||
| --comments "Deployment validated in canary region" | ||
| ``` | ||
|
|
||
| ### StageProgression Examples | ||
| Create a StageProgression for the Canary stage: | ||
| ```bash | ||
| az changesafety stageprogression create \ | ||
| --change-record-name changerecord-webapp-rollout \ | ||
| -n canary-progression \ | ||
| --stage-reference Canary \ | ||
| --status InProgress | ||
| ``` | ||
|
|
||
| Update StageProgression to mark stage as completed: | ||
| ```bash | ||
| az changesafety stageprogression update \ | ||
| --change-record-name changerecord-webapp-rollout \ | ||
| -n canary-progression \ | ||
| --status Completed \ | ||
| --comments "Canary validation passed" | ||
| ``` | ||
|
|
||
| ## Additional Information | ||
| - View command documentation: `az changesafety -h` | ||
| - Remove the extension when no longer needed: `az extension remove --name azure-changesafety` | ||
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,42 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # | ||
| # Code generated by aaz-dev-tools | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure.cli.core import AzCommandsLoader | ||
| from azext_changesafety._help import helps # pylint: disable=unused-import | ||
|
|
||
|
|
||
| class ChangeSafetyCommandsLoader(AzCommandsLoader): | ||
|
|
||
| def __init__(self, cli_ctx=None): | ||
| from azure.cli.core.commands import CliCommandType | ||
| custom_command_type = CliCommandType( | ||
| operations_tmpl='azext_changesafety.custom#{}') | ||
| super().__init__(cli_ctx=cli_ctx, | ||
| custom_command_type=custom_command_type) | ||
|
|
||
| def load_command_table(self, args): | ||
| from azext_changesafety.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_changesafety._params import load_arguments | ||
| load_arguments(self, command) | ||
|
|
||
|
|
||
| COMMAND_LOADER_CLS = ChangeSafetyCommandsLoader |
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.