Skip to content

[Draft] Support az what-if - #32138

Draft
Shiying Chen (MoChilia) wants to merge 20 commits into
Azure:devfrom
MoChilia:whatif
Draft

[Draft] Support az what-if#32138
Shiying Chen (MoChilia) wants to merge 20 commits into
Azure:devfrom
MoChilia:whatif

Conversation

@MoChilia

@MoChilia Shiying Chen (MoChilia) commented Sep 18, 2025

Copy link
Copy Markdown
Member

Related command

az what-if
--what-if

Description

A new Azure CLI command for creating a sandboxed what-if simulation of Azure CLI scripts to visualize infrastructure changes before execution.
--script-path: Specify the path to a script file containing Azure CLI commands to be executed.
--no-pretty-print: Disable pretty-printing of the output.

Include pr #32131 contributed by ZelinWang (@wangzelin007)
az vm --what-if
az sql --what-if

Testing Guide

Ensure you have run az login

  • Simulate a what-if scenario for a provided script
    az what-if --script-path "/path/to/your/script.sh
  • Simulate a what-if scenario for a specific subscription
    az what-if --script-path "/path/to/your/script.sh" --subscription 00000000-0000-0000-0000-000000000000

History Notes

[What-if] az what-if: Support az what-if
[What-if]: Support --what-if


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Sep 18, 2025

Copy link
Copy Markdown
️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented Sep 18, 2025

Copy link
Copy Markdown
⚠️AzureCLI-BreakingChangeTest
⚠️sql
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd sql server create cmd sql server create added parameter what_if
⚠️util
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd what-if cmd what-if added
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd vm create cmd vm create added parameter what_if

@yonzhan

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions

Copy link
Copy Markdown

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new az what-if command that allows users to simulate Azure CLI scripts and visualize infrastructure changes before execution. The command analyzes a script file and sends it to an external service for what-if analysis.

  • Adds a new what-if command to the util module
  • Implements script parsing and external API integration for what-if simulation
  • Provides help documentation and parameter definitions for the new command

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/util/custom.py Core implementation of the show_what_if function that reads scripts and calls external service
src/azure-cli/azure/cli/command_modules/util/commands.py Command registration for the new what-if command
src/azure-cli/azure/cli/command_modules/util/_params.py Parameter definition for the script path argument
src/azure-cli/azure/cli/command_modules/util/_help.py Help documentation and usage examples for the command
src/azure-cli/azure/cli/command_modules/util/tests/latest/test_whatif_script.sh Test script file for the what-if functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/azure-cli/azure/cli/command_modules/util/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/util/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/util/custom.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/util/_params.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/util/_help.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/util/custom.py Outdated
* Add what if feature

* Update src/azure-cli-core/azure/cli/core/commands/__init__.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* minor fix

* Update what_if.py

---------

Co-authored-by: ZelinWang <zelinwang@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MoChilia
Shiying Chen (MoChilia) marked this pull request as draft September 22, 2025 08:11
@MoChilia

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 3 pipeline(s).

@yonzhan Yong Zhang (yonzhan) added this to the Backlog milestone Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants