Skip to content

[Core] Update global policy argument --acquire-policy-token to pick up new api-version and propagate correlation-id#33661

Open
Celinadhh wants to merge 1 commit into
Azure:devfrom
Celinadhh:acquire-policy-token
Open

[Core] Update global policy argument --acquire-policy-token to pick up new api-version and propagate correlation-id#33661
Celinadhh wants to merge 1 commit into
Azure:devfrom
Celinadhh:acquire-policy-token

Conversation

@Celinadhh

@Celinadhh Celinadhh commented Jun 26, 2026

Copy link
Copy Markdown
Member

Related command

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

Description

This PR adds a few optimizations and updates to #31741. We are updating the api-version used for the acquire-policy-token calls so more information is outputted to the user. And also making sure the acquire-policy-token call uses the same correlation-id as its outgoing calls for easier debugging.

Testing Guide

  1. Apply an invoke policy on your resource.
  2. Delete your resource directly - failure expected.
  3. Delete your resource with --acquire-policy-token, expect call to acquire-policy-token API with 2025-11-01 api-version that uses same correlation-id as resource delete.

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

@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi @Celinadhh,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd

Copy link
Copy Markdown
Validation for Breaking Change Starting...

Thanks for your contribution!

@Celinadhh

Copy link
Copy Markdown
Member Author

Confirmed correlationId and api-version:
image

image image

@Celinadhh Celinadhh marked this pull request as ready for review June 26, 2026 17:06
Copilot AI review requested due to automatic review settings June 26, 2026 17:06
@Celinadhh

Copy link
Copy Markdown
Member Author

@notyashhh PTAL, thank you! :)

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 updates the internal acquirePolicyToken request made when users opt into the global --acquire-policy-token behavior, aligning it with a newer ARM API version and ensuring correlation ID continuity to simplify end-to-end debugging.

Changes:

  • Bump acquirePolicyToken api-version from 2025-03-01 to 2025-11-01.
  • Reuse (or generate and set) x-ms-correlation-request-id so the acquirePolicyToken call shares the same correlation ID as the gated operation.

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

correlation_id = http_request.headers.get('x-ms-correlation-request-id')
if not correlation_id:
correlation_id = str(uuid.uuid4())
http_request.headers['x-ms-correlation-request-id'] = correlation_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wondering why you add the new correlation id to the incoming header when one isn't there. Is it used in creating the token (or for something else)?

@Celinadhh Celinadhh Jun 26, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

http_request is the original request (e.g. a storage account delete). If there is no existing correlation-id, we generate the correlation-id in the acquire-policy-token call, and propagate the same one to http_request (storage account delete).

@mentat9 mentat9 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM (modulo non-blocking question).

Also, I'm assuming you verified the policy context information comes back to the UI in the case no token is issued.

@Celinadhh

Copy link
Copy Markdown
Member Author

LGTM (modulo non-blocking question).

Also, I'm assuming you verified the policy context information comes back to the UI in the case no token is issued.

Yes, this was validated. Attaching screenshot below:
image

@yonzhan

yonzhan commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Core

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

Labels

act-platform-engineering-squad Auto-Assign Auto assign by bot Core CLI core infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants