You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move Foundry remote-tool connection provisioning to Bicep #14
The postprovision hooks currently create the aigw-github Foundry project connection imperatively with azd ai connection create. Project connections are ARM resources (Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview), so this part of the deployment can potentially be declarative and owned by Bicep.
The original script-based implementation avoided management-plane timing issues and needs the generated AI Gateway API key. Moving it requires a stable, secure way to retrieve and pass that key without exposing it in deployment outputs, logs, or source-controlled configuration.
Proposed work
Declare the aigw-github remote-tool project connection in Bicep.
Wire its target to the AI Gateway GitHub MCP ToolServer endpoint.
Supply the Api-Key custom credential securely from the generated gateway key.
Handle the cross-resource-group dependency between the Foundry project and AI Gateway resources.
Remove azd ai connection create from both POSIX and PowerShell postprovision hooks after the Bicep path is reliable.
Keep toolbox creation in postprovision because toolboxes use the Foundry data-plane API rather than ARM.
Keep runtime model-route readiness checks and failed-resource recovery in scripts because they are imperative/data-plane operations.
Acceptance criteria
A fresh azd up creates the remote-tool connection without a CLI connection-create step.
Re-running azd up is idempotent.
The gateway API key is not exposed in Bicep outputs or command logs.
The toolbox resolves and attaches the Bicep-created connection successfully.
POSIX and Windows deployment paths remain equivalent.
Focused deployment/configuration regression coverage and documentation are updated.
Dependency / investigation
Confirm a stable API-key retrieval contract (listSecrets versus listValues) and whether the secret can be referenced safely during ARM deployment before implementing the migration.
@copilot Please implement this on top of current main (which now provisions Microsoft.ApiManagement/aigateways/apiKeys@2025-09-01-preview (apiKeys/default) declaratively in infra/ai-gateway/main.bicep):
Architecture & Secret Handling:
In infra/ai-gateway/main.bicep (or a dedicated child module deployed into the foundry-agents resource group after aiGateway completes), retrieve the generated key from defaultApiKey (Microsoft.ApiManagement/aigateways/apiKeys@2025-09-01-preview) using defaultApiKey.listSecrets().key (and verify whether Bicep/ARM supports listSecrets().key directly on existing or created apiKeys/default without exposing the secret in deployment outputs).
Pass the secret only through a @secure() param to a Bicep module scoped to agentsRg that declares Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview named aigw-github (category: 'RemoteTool', authType: 'CustomKeys', target: '${aiGateway.outputs.gatewayUrl}/default/mcp/github/mcp', credentials: { keys: { 'Api-Key': gatewayApiKey } }, isSharedToAll: true, metadata: { type: 'custom_MCP' }).
Ensure the gateway API key is never emitted as a Bicep output.
Activity
paulyuk commentedon Oct 25, 2026
@copilot Please implement this on top of current
main(which now provisionsMicrosoft.ApiManagement/aigateways/apiKeys@2025-09-01-preview(apiKeys/default) declaratively ininfra/ai-gateway/main.bicep):Architecture & Secret Handling:
infra/ai-gateway/main.bicep(or a dedicated child module deployed into thefoundry-agentsresource group afteraiGatewaycompletes), retrieve the generated key fromdefaultApiKey(Microsoft.ApiManagement/aigateways/apiKeys@2025-09-01-preview) usingdefaultApiKey.listSecrets().key(and verify whether Bicep/ARM supportslistSecrets().keydirectly onexistingor createdapiKeys/defaultwithout exposing the secret in deployment outputs).@secure() paramto a Bicep module scoped toagentsRgthat declaresMicrosoft.CognitiveServices/accounts/projects/connections@2025-04-01-previewnamedaigw-github(category: 'RemoteTool',authType: 'CustomKeys',target: '${aiGateway.outputs.gatewayUrl}/default/mcp/github/mcp',credentials: { keys: { 'Api-Key': gatewayApiKey } },isSharedToAll: true,metadata: { type: 'custom_MCP' }).Postprovision Scripts (
infra/scripts/configure-ai-gateway.sh&infra/scripts/configure-ai-gateway.ps1):azd ai connection createcall onceaigw-githubis provisioned by Bicep, while keeping:listSecretsretrieval to saveAI_GATEWAY_API_KEYinto the localazdenvironment for local dev (create-dev-env.sh),toolServers/githubregistration (which requires the localGH_TOKEN),repo-digest-toolsToolbox creation referencingproject_connection_id: "aigw-github".Tests & Documentation:
tests/test-ai-gateway-model-registration.sh,IMPLEMENTATION_NOTES.md, andinfra/**/README.mdto reflect declarativeaigw-githubconnection provisioning.