Repository navigation
Use ProjectManagedIdentity for Foundry connections and fix AI Gateway MCP wire route - #33
Merged
Paul Yuknewicz (paulyuk) merged 1 commit intoNov 2, 2026
Conversation
… MCP wire route - Switch Foundry appInsightsConnection to ProjectManagedIdentity with Monitoring Metrics Publisher RBAC on Application Insights - Switch Foundry aigw-github connection to ProjectManagedIdentity (audience https://azure-api.net/aigateway) with AI Gateway User RBAC (caad7a21-134e-43f4-a550-c5ffc17e051c) on AI Gateway - Fix aigw-github target route from /default/mcp/github/mcp (HTTP 404) to /default/toolservers/github/mcp (HTTP 200) - Fix runtimeApiKey.listSecrets() fallback to read primaryKey (live ARM response property) before key - Add declarative toolServers/github support when githubMcpAuthorization is supplied - Support keyless Entra ID bearer token auth (https://azure-api.net/aigateway/.default) in repo_digest_agent.py when AZURE_AI_GATEWAY_API_KEY is unset Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4448b1aa-1ea5-4c5f-af63-7ec98b7acb9e
Paul Yuknewicz (paulyuk)
deleted the
copilot/bicep-managed-identity-and-wire-fixes
branch
November 2, 2026 00:30
This was referenced Nov 5, 2026
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.
Problem
appInsightsConnection(Microsoft.CognitiveServices/accounts/connections) authenticated to Application Insights usingauthType: 'ApiKey'andappInsights.properties.InstrumentationKeyinstead ofProjectManagedIdentityandConnectionString.aigw-github(Microsoft.CognitiveServices/accounts/projects/connections) authenticated from Foundry Toolbox to AI Gateway usingauthType: 'CustomKeys'(Api-Key) instead ofProjectManagedIdentitywithAI Gateway UserRBAC.repo_digest_agent.pyrequiredAZURE_AI_GATEWAY_API_KEYeven when running under an identity withAI Gateway UserRBAC.aigw-githubconnection (#27):aigw-githubtargeted<gatewayUrl>/default/mcp/github/mcp, which returnsHTTP 404 Resource not foundon the live AI Gateway data plane; the live route fortoolServers/githubis<gatewayUrl>/default/toolservers/github/mcp.runtimeApiKey!.listSecrets().keyfails when evaluated on live ARM (2025-09-01-preview) becauselistSecrets()returns{"primaryKey": "...", "secondaryKey": "..."}rather thankey.Solution
infra/foundry-agents/main.bicep):appInsightsConnectiontoauthType: 'ProjectManagedIdentity'(@2025-06-01) withmetadata.ApplicationInsightsConnectionString: appInsights.properties.ConnectionString.Monitoring Metrics Publisher(3913510d-42f4-4e42-8a64-420c390055eb) on Application Insights to the Foundry account and project system-assigned managed identities.infra/foundry-agents/github-connection.bicep,infra/ai-gateway/main.bicep,infra/main.bicep):aigw-githubtarget URL to${normalizedGatewayUrl}/default/toolservers/github/mcp.aigw-github(@2025-06-01) toauthType: 'ProjectManagedIdentity'withaudience: 'https://azure-api.net/aigateway'.AI Gateway User(caad7a21-134e-43f4-a550-c5ffc17e051c) onMicrosoft.ApiManagement/aigatewaysto the Foundry project identity, Foundry account identity, and optional developerprincipalId.CustomKeysfallback (useManagedIdentityForFoundryConnections: false) to readruntimeApiKey!.listSecrets().?primaryKey ?? runtimeApiKey!.listSecrets().?key ?? ''.toolServers/githubheader registration when@secure() param githubMcpAuthorizationis supplied at deployment time.repo_digest_agent.py):https://azure-api.net/aigateway/.default) viaDefaultAzureCredential/ManagedIdentityCredentialwhenAZURE_AI_GATEWAY_API_KEYis unset, while preservingApi-Keyheader support whenAZURE_AI_GATEWAY_API_KEYis configured.Canonical DX
Keyless Bicep connection (
infra/foundry-agents/github-connection.bicep)Keyless local or hosted agent execution
Validation
infra/foundry-agents/main.bicepandinfra/ai-gateway/main.bicepto live Azure (rg-aigw3-7vezhdb5-foundryagentsandrg-aigateway-quickstart) and verified all created ARM resources and role assignments.AZURE_AI_GATEWAY_API_KEYunset:https://azure-api.net/aigateway/.default) -> AI Gateway/default/models/openai/v1/chat/completions(gpt-latest->gpt-6.1-sol-2026-09-29,HTTP 200)./default/toolservers/github/mcp(tools/list,HTTP 200)./toolboxes/repo-digest-tools/versions/1/mcp?api-version=v1) ->aigw-github(ProjectManagedIdentity) -> AI Gateway (/default/toolservers/github/mcp) -> GitHub MCP (aigw-github___github_list_pull_requests,HTTP 200).repo_digest_agent.build_agent().run(...)executing parallel tool calls (list_pull_requests,list_issues,actions_list) through Foundry Toolbox and returning the live repository digest with zero API keys.bash tests/test-ai-gateway-model-registration.shand all 18 unit tests (python -m unittest discover -s tests -p "test_*.py").