Skip to content

Conversation

@MoChilia
Copy link
Member

@MoChilia MoChilia commented Sep 18, 2025

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 @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.

Copilot AI review requested due to automatic review settings September 18, 2025 02:00
@azure-client-tools-bot-prd
Copy link

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

️✔️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
Copy link

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

⚠️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
Collaborator

yonzhan commented Sep 18, 2025

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

@github-actions
Copy link

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>

@MoChilia MoChilia self-assigned this Sep 18, 2025
Copy link
Contributor

Copilot AI left a comment

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.

MoChilia and others added 2 commits September 22, 2025 15:56
* 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 MoChilia requested a review from yanzhudd as a code owner September 22, 2025 08:07
@MoChilia MoChilia marked this pull request as draft September 22, 2025 08:11
@MoChilia MoChilia removed this from the October 2025 (2025-10-14) milestone Nov 11, 2025
@MoChilia
Copy link
Member Author

MoChilia commented Dec 1, 2025

/azp run

@azure-pipelines
Copy link

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
Collaborator

yonzhan commented Dec 1, 2025

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yonzhan 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.

3 participants