Skip to content

{Core} Remove Opt-In for --acquire-policy-token Flag#32883

Merged
notyashhh merged 2 commits intodevfrom
yash/changesafety-remove-policy-flag
Mar 16, 2026
Merged

{Core} Remove Opt-In for --acquire-policy-token Flag#32883
notyashhh merged 2 commits intodevfrom
yash/changesafety-remove-policy-flag

Conversation

@notyashhh
Copy link
Copy Markdown
Member

@notyashhh notyashhh commented Mar 3, 2026

Related command

All mutating az commands (global change in azure-cli-core)
Example: az keyvault create, az keyvault set-policy, az network vnet create, etc.

Description

  • Removes the core.enable_policy_token configuration flag that previously gated the Change Safety (Azure Policy Invoke) feature behind an opt-in.
  • Previously, users had to run az config set core.enable_policy_token=true to access the --acquire-policy-token and --change-reference global arguments.
  • With this change, these arguments are always registered on all mutating commands (excluding list/show) without any configuration needed.
  • This is not a breaking change, the arguments are additive and optional. They have no effect unless explicitly passed. Existing command behavior is entirely unchanged.

Testing Guide

  1. Verify arguments appear on mutating commands without any config:
az keyvault create --help

Confirm --acquire-policy-token and --change-reference appear under "Global Policy Arguments".

  1. Verify arguments do not appear on read-only commands:
az keyvault list --help
az keyvault show --help

Confirm the "Global Policy Arguments" section is absent.

  1. Verify normal commands are unaffected when --acquire-policy-token is not passed:
az keyvault create --name myVault --resource-group myRG --location eastus

Confirm no change in behavior or output.

History Notes

[Core] az *: Make --acquire-policy-token and --change-reference global arguments available by default, removing the need for core.enable_policy_token configuration


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 March 3, 2026 01:39
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 3, 2026

️✔️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
️✔️postgresql
️✔️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
Copy Markdown

azure-client-tools-bot-prd bot commented Mar 3, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 3, 2026

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

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>

Copy link
Copy Markdown
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 removes the config-based feature flag gating for the “Global Policy” arguments, making the global policy argument registration always active in azure-cli-core.

Changes:

  • Removed the core.enable_policy_token config check.
  • Always registers the EVENT_INVOKER_POST_CMD_TBL_CREATE hook to add --change-reference and --acquire-policy-token to eligible commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +230 to +231
from knack import events
cli_ctx.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, add_global_policy_argument)
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

PR description is currently the template and doesn’t document the impact of making --change-reference/--acquire-policy-token always available (potential CLI surface-area/breaking-change implications) or how it was tested. Please fill in the related command(s), rationale, and a concrete testing guide so reviewers can validate the behavior change.

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +231
from knack import events
cli_ctx.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, add_global_policy_argument)
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

Removing the feature-flag means these global arguments are now registered for every command table load. There are no unit tests covering that the new global options are present where expected (and skipped for list/show). Consider adding a core test (e.g., in azure/cli/core/tests/test_parser.py or test_help.py) that builds a parser for a representative command and asserts the presence/absence of --change-reference and --acquire-policy-token.

Copilot uses AI. Check for mistakes.
@notyashhh notyashhh requested a review from yanzhudd as a code owner March 5, 2026 06:17
@necusjz
Copy link
Copy Markdown
Member

necusjz commented Mar 9, 2026

shall we add the context in the description of that pr?

@notyashhh notyashhh changed the title [ChangeSafety] Remove Policy Token Flag [Core] Remove Policy Token Flag Mar 15, 2026
@notyashhh notyashhh changed the title [Core] Remove Policy Token Flag [Core] Remove Opt-In for --AcquirePolicyToken Flag Mar 15, 2026
@notyashhh
Copy link
Copy Markdown
Member Author

@necusjz, Can you please review?

@necusjz necusjz changed the title [Core] Remove Opt-In for --AcquirePolicyToken Flag {Core} Remove Opt-In for --AcquirePolicyToken Flag Mar 16, 2026
@notyashhh notyashhh merged commit 5a7e6a2 into dev Mar 16, 2026
90 checks passed
@jiasli
Copy link
Copy Markdown
Member

jiasli commented Mar 16, 2026

--AcquirePolicyToken doesn't follow Azure CLI's naming convention. It should be --acquire-policy-token.

@jiasli
Copy link
Copy Markdown
Member

jiasli commented Mar 16, 2026

According to

- Fork the https://github.com/Azure/azure-cli/ repository into your private GitHub account

the source branch of a PR should reside in your forked repo.

@notyashhh notyashhh changed the title {Core} Remove Opt-In for --AcquirePolicyToken Flag {Core} Remove Opt-In for --acquire-policy-token Flag Mar 16, 2026
nddq pushed a commit to nddq/azure-cli that referenced this pull request Mar 25, 2026
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.

5 participants