Skip to content

[Identity] Skip IMDS probe when MI selected in DAC via env - #43080

Merged
Paul Van Eck (pvaneck) merged 6 commits into
Azure:mainfrom
pvaneck:identity-mi-dac-retry
Oct 4, 2025
Merged

Paul Van Eck (pvaneck) merged 6 commits into
Azure:mainfrom
pvaneck:identity-mi-dac-retry

Conversation

@pvaneck

@pvaneck Paul Van Eck (pvaneck) commented Sep 20, 2025 •

Copy link
Copy Markdown
Member

When the environment variable AZURE_TOKEN_CREDENTIALS is explicitly set to ManagedIdentityCredential, DefaultAzureCredential should not do IMDS probing.

Closes: #43046

When the environment variable AZURE_TOKEN_CREDENTIALS is explicitly set to
ManagedIdentityCredential, DefaultAzureCredential should not do IMDA
probing.

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>

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 implements a performance optimization for DefaultAzureCredential when the AZURE_TOKEN_CREDENTIALS environment variable is explicitly set to "managedidentitycredential". The change eliminates the IMDS endpoint probe that occurs when using ManagedIdentityCredential within the credential chain, allowing it to skip directly to token acquisition with full retry logic.

  • Adds _skip_probe_in_chain parameter to ManagedIdentityCredential and ImdsCredential classes
  • Modifies DefaultAzureCredential to detect when only ManagedIdentityCredential is enabled and skip the probe
  • Updates the IMDS endpoint probing logic to respect the skip flag

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
azure/identity/_credentials/default.py Sets _skip_probe_in_chain=True when only managed identity is enabled in DefaultAzureCredential
azure/identity/aio/_credentials/default.py Async version of the same DefaultAzureCredential changes
azure/identity/_credentials/managed_identity.py Adds _skip_probe_in_chain parameter and passes it to ImdsCredential
azure/identity/aio/_credentials/managed_identity.py Async version of the same ManagedIdentityCredential changes
azure/identity/_credentials/imds.py Modifies probe logic to skip when _skip_probe_in_chain is True
azure/identity/aio/_credentials/imds.py Async version of the same ImdsCredential probe changes
tests/test_default.py Updates test expectations to include new _skip_probe_in_chain parameter
tests/test_default_async.py Async version of the same test updates
tests/test_token_credentials_env.py Adds test verifying probe is skipped when environment variable is set
tests/test_token_credentials_env_async.py Async version of the new test
CHANGELOG.md Documents the behavior change

Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
@pvaneck
Paul Van Eck (pvaneck) merged commit 07395dd into Azure:main Oct 4, 2025
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure Identity SDK Improvements Oct 4, 2025
@pvaneck
Paul Van Eck (pvaneck) deleted the identity-mi-dac-retry branch October 4, 2025 00:13
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.

DAC: Disable probe and enable retries when ManagedIdentityCredential is selected via env var

3 participants