[Identity] Update AZURE_TOKEN_CREDENTIALS to allow specific creds - #41709
Merged
Conversation
Now users of DefaultAzureCredential can specify a specific credential in the DAC chain when using the AZURE_TOKEN_CREDENTIALS environment variable. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
pvaneck
force-pushed
the
identity-phase-2
branch
from
June 27, 2025 01:59
0eec386 to
ad8d6ce
Compare
pvaneck
marked this pull request as ready for review
June 27, 2025 02:38
pvaneck
requested review from
KarishmaGhiya,
chlowell,
christothes,
maorleger,
minhanh-phan and
scottaddie
June 27, 2025 02:38
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enables users to select a specific credential within DefaultAzureCredential by setting the AZURE_TOKEN_CREDENTIALS environment variable, refactors the credential-exclusion logic into a reusable helper, adds comprehensive tests for both async and sync chains, and updates versioning and metadata to reflect the new beta release.
- Introduced
process_credential_exclusionsin internal utils and wired it into async & syncDefaultAzureCredentialconstructors. - Expanded test coverage for async and sync chains to validate specific credential selection, case-insensitivity, invalid values, and user overrides.
- Updated package metadata (setup.py classifier, version, changelog) for the 1.24.0b1 beta release.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/identity/azure-identity/tests/test_token_credentials_env_async.py | Added async tests covering specific credential selection via env var. |
| sdk/identity/azure-identity/tests/test_token_credentials_env.py | Added sync tests covering specific credential selection via env var. |
| sdk/identity/azure-identity/setup.py | Changed development status classifier to Beta. |
| sdk/identity/azure-identity/azure/identity/aio/_credentials/default.py | Refactored async DefaultAzureCredential to use process_credential_exclusions. |
| sdk/identity/azure-identity/azure/identity/_credentials/default.py | Refactored sync DefaultAzureCredential to use process_credential_exclusions. |
| sdk/identity/azure-identity/azure/identity/_internal/utils.py | Introduced process_credential_exclusions helper for managing exclusions. |
| sdk/identity/azure-identity/azure/identity/_internal/init.py | Exported process_credential_exclusions in internal package init. |
| sdk/identity/azure-identity/azure/identity/_version.py | Bumped version to 1.24.0b1. |
| sdk/identity/azure-identity/CHANGELOG.md | Documented new AZURE_TOKEN_CREDENTIALS feature and version update. |
Comments suppressed due to low confidence (2)
sdk/identity/azure-identity/azure/identity/aio/_credentials/default.py:128
- The class docstring for
DefaultAzureCredentialshould include a description of the newAZURE_TOKEN_CREDENTIALSenvironment variable and how it controls which credential is used, ensuring users know how to configure this feature.
# Define credential configuration mapping (async version)
sdk/identity/azure-identity/azure/identity/_credentials/default.py:136
- Add documentation in the class docstring to explain the supported values of
AZURE_TOKEN_CREDENTIALSand how the exclusion flags interact, so the syncDefaultAzureCredentialAPI matches its behavior.
# Define credential configuration mapping
chlowell
reviewed
Jun 27, 2025
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
xiangyan99
reviewed
Jul 1, 2025
joshfree
approved these changes
Jul 1, 2025
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
scottaddie
reviewed
Jul 8, 2025
chlowell
reviewed
Jul 8, 2025
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
chlowell
approved these changes
Jul 9, 2025
xiangyan99
reviewed
Jul 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now, users of DefaultAzureCredential can specify a specific credential in the DAC chain when using the
AZURE_TOKEN_CREDENTIALSenvironment variable.InteractiveBrowserCredential), if that credential is set in the env var, then its inclusion will be prioritized. For example,AZURE_TOKEN_CREDENTIALS=InteractiveBrowserCredentialwill makeDefaultAzureCredential()useInteractiveBrowserCredential.Closes: #39784