Skip to content

[Core] Update global policy argument --acquire-policy-token to pick up new api-version and update error message - #34526

Open
ccz77 (Celinadhh) wants to merge 1 commit into
Azure:devfrom
Celinadhh:acquire-policy-token-error
Open

ccz77 (Celinadhh) wants to merge 1 commit into
Azure:devfrom
Celinadhh:acquire-policy-token-error

Conversation

@Celinadhh

@Celinadhh ccz77 (Celinadhh) commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests Suppressions
️✔️ None ️✔️ 130/130 ️✔️ None

Related command
All cli commands where users set --acquire-policy-token

Description

This PR adds a few optimizations and updates to #33661. We are updating the api-version used for the acquire-policy-token calls so we can now support RG scope acquisition. And also updating the error message when no policy token is returned to be more user friendly.

Testing Guide
Apply an invoke policy on your resource.
Delete your resource directly - failure expected.
Delete your resource with --acquire-policy-token, expect call to acquire-policy-token API with 2026-07-01 api-version that uses same resource group as resource delete.

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

Copilot AI balanced review requested due to automatic review settings December 3, 2026 19:45
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

The URL and tests use api-version=2026-07-01 while the testing guide specifies 2025-07-01, leaving the intended service version unresolved.

1 open issue
What changed in this PR

Updates Azure CLI’s shared --acquire-policy-token hook to support resource-group-scoped acquisition and clearer policy-denial errors.

Changes:

  • Derives acquisition scope from the outgoing request and changes the API version.
  • Clarifies errors when the response contains no token.
  • Adds unit tests for scope selection, token handling, and error behavior.
File Description
src/​azure-cli-core/​azure/​cli/​core/​tests/​test_sdk_policies.py Adds policy-token hook coverage.
src/​azure-cli-core/​azure/​cli/​core/​sdk/​policies.py Updates acquisition scope, API version, and denial messages.

Review effort: Balanced

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants