Skip to content

fix(corpus_search): pin DefaultAzureCredential to MI client id#200

Merged
miguelgfierro merged 1 commit into
mainfrom
fix/blob-registry-mi-client-id
May 19, 2026
Merged

fix(corpus_search): pin DefaultAzureCredential to MI client id#200
miguelgfierro merged 1 commit into
mainfrom
fix/blob-registry-mi-client-id

Conversation

@miguelgfierro
Copy link
Copy Markdown
Contributor

Summary

AzureCorpusBackendRegistry now reads an optional CORPUS_AZURE_MANAGED_IDENTITY_CLIENT_ID env var and passes it to DefaultAzureCredential(managed_identity_client_id=...).

Why

On the MCP server, AZURE_CLIENT_ID is set to the OAuth App Registration's client id (used by OAuthJWTMiddleware for JWT audience validation). DefaultAzureCredential picks up that same env var and tries it as the MI's client id, so the MI step of the credential chain fails:

ManagedIdentityCredential: ... No User Assigned or Delegated Managed Identity found for specified ClientId

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

  • Ruff clean
  • After deploy + setting CORPUS_AZURE_MANAGED_IDENTITY_CLIENT_ID on firefly-mcp, list_corpora succeeds against the blob container

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.
@miguelgfierro miguelgfierro merged commit ff3ed23 into main May 19, 2026
9 checks passed
@miguelgfierro miguelgfierro deleted the fix/blob-registry-mi-client-id branch May 19, 2026 13:58
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant