fix(corpus_search): pin DefaultAzureCredential to MI client id#200
Merged
Conversation
When the MCP server is configured with OAuth (`AZURE_CLIENT_ID` set to the App Registration's client id for JWT audience validation), `DefaultAzureCredential` picks up that same env var and tries to use it as the managed identity's client id. The MI step fails with "No User Assigned or Delegated Managed Identity found for specified ClientId" because that GUID isn't a managed identity. Accept an optional `managed_identity_client_id` kwarg on `AzureCorpusBackendRegistry` and a `CORPUS_AZURE_MANAGED_IDENTITY_CLIENT_ID` env var on `build_registry`. When set, pass through to `DefaultAzureCredential(managed_identity_client_id=...)` so only the MI step of the credential chain is pinned; other steps (env credential, workload identity, az CLI for local dev) are unaffected.
ancongui
pushed a commit
that referenced
this pull request
May 31, 2026
#200) When the MCP server is configured with OAuth (`AZURE_CLIENT_ID` set to the App Registration's client id for JWT audience validation), `DefaultAzureCredential` picks up that same env var and tries to use it as the managed identity's client id. The MI step fails with "No User Assigned or Delegated Managed Identity found for specified ClientId" because that GUID isn't a managed identity. Accept an optional `managed_identity_client_id` kwarg on `AzureCorpusBackendRegistry` and a `CORPUS_AZURE_MANAGED_IDENTITY_CLIENT_ID` env var on `build_registry`. When set, pass through to `DefaultAzureCredential(managed_identity_client_id=...)` so only the MI step of the credential chain is pinned; other steps (env credential, workload identity, az CLI for local dev) are unaffected. Co-authored-by: miguelgfierro <miguelgfierro@users.noreply.github.com>
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.
Summary
AzureCorpusBackendRegistrynow reads an optionalCORPUS_AZURE_MANAGED_IDENTITY_CLIENT_IDenv var and passes it toDefaultAzureCredential(managed_identity_client_id=...).Why
On the MCP server,
AZURE_CLIENT_IDis set to the OAuth App Registration's client id (used byOAuthJWTMiddlewarefor JWT audience validation).DefaultAzureCredentialpicks up that same env var and tries it as the MI's client id, so the MI step of the credential chain fails:Pinning the MI step to a separate, explicit env var sidesteps the collision without touching
AZURE_CLIENT_ID(which other layers depend on).Test plan
CORPUS_AZURE_MANAGED_IDENTITY_CLIENT_IDonfirefly-mcp,list_corporasucceeds against the blob container