[ARM] Deployment stacks What-If support#32854
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
a5a243b to
42c7914
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new az stack-whatif command surface to the resource module to create/show/list/delete deployment stack What-If results across RG/subscription/management-group scopes, including a dedicated pretty-printer for stack What-If output and accompanying tests/recordings.
Changes:
- Register new
stack-whatif {group|sub|mg} {create|show|list|delete}command groups and arguments, plus help text and linter exclusions. - Add a stack What-If pretty formatter (
DeploymentStacksWhatIfResultFormatter) and extend shared color/formatting utilities. - Add live-scenario tests + recordings, and a unit test + sample JSON for formatter output.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/service_name.json | Map az stack-whatif to the ARM “Resource Manager” service link. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py | New unit test for stack What-If pretty formatting. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_stacks.py | New scenario tests for stack-whatif create/show/list/delete. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_subscription.yaml | Playback recording for subscription-scope stack-whatif scenario. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_resource_group.yaml | Playback recording for RG-scope stack-whatif scenario. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_management_group.yaml | Playback recording for MG-scope stack-whatif scenario. |
| src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json | Sample stack What-If payload used by formatter unit tests. |
| src/azure-cli/azure/cli/command_modules/resource/linter_exclusions.yml | Add linter exclusions for stack-whatif command groups/params. |
| src/azure-cli/azure/cli/command_modules/resource/custom.py | Implement stack-whatif create/show pretty-print behavior and wiring to the formatter. |
| src/azure-cli/azure/cli/command_modules/resource/commands.py | Register new stack-whatif command groups and operations. |
| src/azure-cli/azure/cli/command_modules/resource/_utils.py | Add str_lower_eq helper used by stack-whatif formatter comparisons. |
| src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py | New pretty-printer for stack What-If results (stack-level + managed resource changes + diagnostics). |
| src/azure-cli/azure/cli/command_modules/resource/_params.py | Add --no-color, introduce --stack-id for stack-whatif, and share argument wiring across stack/stack-whatif. |
| src/azure-cli/azure/cli/command_modules/resource/_help.py | Add help entries + examples for az stack-whatif across scopes. |
| src/azure-cli/azure/cli/command_modules/resource/_formatters.py | Adjust deployment What-If formatter behavior around “Unknown” scopes / missing relative IDs. |
| src/azure-cli/azure/cli/command_modules/resource/_color.py | Extend color utilities (CYAN) and add indentation/insert helpers used by the new formatter. |
| src/azure-cli-core/azure/cli/core/helpIndex.latest.json | Add top-level help index entry for stack-whatif. |
| src/azure-cli-core/azure/cli/core/commandIndex.latest.json | Add stack-whatif to command index; also modifies network module mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "network": [ | ||
| "azure.cli.command_modules.network", | ||
| "azure.cli.command_modules.privatedns" | ||
| "azure.cli.command_modules.network" |
There was a problem hiding this comment.
commandIndex.latest.json drops azure.cli.command_modules.privatedns from the network command group. Since azure/cli/command_modules/privatedns/ still exists, this likely breaks az network private-dns ... command loading under the optimized loader. Please regenerate the command index or re-add the privatedns module to the network entry.
| "azure.cli.command_modules.network" | |
| "azure.cli.command_modules.network", | |
| "azure.cli.command_modules.privatedns" |
There was a problem hiding this comment.
Not sure how this happened. I ran the script to update this.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py
Outdated
Show resolved
Hide resolved
src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Related command
az stack-whatifDescription
Adds
stack-whatifcommands to Az CLI. This is a new resource type in ARM that stores previews of operations on deployment stacks. This may become a subcommand, or a flag to existing stack commands in the future, depending on customer feedback. The reason this is not added as a subcommand now is there is a subcommand hierarchy conflict:az stack what-if groupconflicts withaz stack groupwherewhat-ifis an action vsgroupwhich is a scope.az stack group what-ifwould operate on a what-if entity, not a stack, which conflicts with the hierarchy.Happy to take other suggestions if
az stack-whatifis not desired.Testing Guide
See
test_resource_stacks.pyfor live test examples. Note at the time of writing, these commands currently only work in Canary regions, but full prod availability is expected by the end of the month.History Notes
[ARM]
az stack-whatif group/sub/mg: Add deployment stacks what-if commands.This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.