Skip to content

[Identity] Allow policy override#46072

Merged
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:identity-override-policies
Apr 24, 2026
Merged

[Identity] Allow policy override#46072
pvaneck merged 1 commit intoAzure:mainfrom
pvaneck:identity-override-policies

Conversation

@pvaneck
Copy link
Copy Markdown
Member

@pvaneck pvaneck commented Apr 2, 2026

Similar to SDK clients, this allows credential pipelines to be customized at the policy level.

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

Enables azure-identity credentials to accept HTTP pipeline policy overrides (similar to azure.core clients), allowing callers to inject/replace built-in policies and insert custom per-call/per-retry policies.

Changes:

  • Updated internal pipeline construction to accept policy instances via kwargs (e.g., headers_policy, per_call_policies, per_retry_policies, retry_policy).
  • Updated IMDS credentials (sync + async) to use a retry_policy instance override instead of retry_policy_class.
  • Added tests and a changelog entry documenting policy overrides.

Reviewed changes

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

Show a summary per file
File Description
sdk/identity/azure-identity/tests/test_pipeline_policy_overrides.py Adds unit tests covering config/policy override behavior and pipeline assembly order.
sdk/identity/azure-identity/azure/identity/aio/_credentials/imds.py Switches async IMDS to accept/provide a retry_policy instance.
sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_arc.py Updates arg name to per_retry_policies for policy injection.
sdk/identity/azure-identity/azure/identity/_internal/pipeline.py Implements policy override wiring and per-call/per-retry insertion around retry.
sdk/identity/azure-identity/azure/identity/_credentials/imds.py Switches sync IMDS to accept/provide a retry_policy instance.
sdk/identity/azure-identity/CHANGELOG.md Documents the new override support.

Comment thread sdk/identity/azure-identity/azure/identity/_internal/pipeline.py Outdated
Comment thread sdk/identity/azure-identity/tests/test_pipeline_policy_overrides.py
Comment thread sdk/identity/azure-identity/tests/test_pipeline_policy_overrides.py Outdated
Comment thread sdk/identity/azure-identity/CHANGELOG.md Outdated
Comment thread sdk/identity/azure-identity/azure/identity/_internal/pipeline.py Outdated
Similar to SDK clients, this allows credential pipelines to be
customized at the policy level.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck pvaneck force-pushed the identity-override-policies branch from ae758fd to cbc280b Compare April 24, 2026 01:24
@pvaneck pvaneck marked this pull request as ready for review April 24, 2026 01:24
@pvaneck pvaneck requested review from a team and xiangyan99 as code owners April 24, 2026 01:24
@github-project-automation github-project-automation Bot moved this from Untriaged to In Progress in Azure Identity SDK Improvements Apr 24, 2026
@pvaneck pvaneck merged commit 8ee83e6 into Azure:main Apr 24, 2026
28 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Azure Identity SDK Improvements Apr 24, 2026
@pvaneck pvaneck deleted the identity-override-policies branch April 24, 2026 19:18
fafhrd91 pushed a commit to fafhrd91/azure-sdk-for-python that referenced this pull request Apr 28, 2026
Similar to SDK clients, this allows credential pipelines to be
customized at the policy level.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants