Repository navigation
Add lab 25: use your gateway's models and tools in Claude Code - #36
Merged
Merged
Conversation
- Publish Claude Opus, Sonnet, and Haiku 5.5 from Foundry behind aliases with a per-caller token limit and an Opus daily budget, and the claude-code key - Point Claude Code at the gateway's Anthropic route with environment variables, and add the Learn MCP server with claude mcp add - Hit the token limit and the budget from Claude Code, carry on with Sonnet, sign in with Entra ID through apiKeyHelper, and suspend the key - Add the notebook, the Bicep template, the architecture diagram, the Troubleshooting section, the catalog entries, and the skill facts - Let the tracks pill wrap on mobile Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
Fixes the two Dependabot alerts on main: - certifi 2026.7.22 -> 2026.10.23 (critical: bundled emSign root CAs with compromised intermediate CA keys; fixed in 2026.10.18) - oauthlib 4.0.0 -> 4.0.1 (high: device workflow secret disclosure) Both are transitive pins. certifi was resolved with uv pip compile --upgrade-package; oauthlib is pinned by hand because the Microsoft package feed proxy doesn't serve 4.0.1 yet. Its metadata is compatible (requires-python >=3.9, no required dependencies; requests-oauthlib 2.0.0 needs oauthlib>=3.0.0), and Foundry builds the agent from PyPI. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
ANTHROPIC_AUTH_TOKEN outranks apiKeyHelper. With both set, Claude Code sends the gateway key as the bearer token and the helper's token only in x-api-key, so the requests still succeed with the key and Entra ID is silently skipped. The lab exports ANTHROPIC_AUTH_TOKEN earlier, so "Don't set" wasn't enough: the Go further tip now says to unset it and keep it out of the settings' env block. The skill fact says the same. The troubleshooting row for the 401 retry hang now names the cause precisely: the key is in ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN. Verified with Claude Code 2.1.319 against a local header-capture server. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
Alex Vieira (vieiraae)
requested review from
Paul Yuknewicz (paulyuk)
and
a balanced review from Copilot
November 11, 2026 20:34
…ctor Namespace imports Align the labs with the product team's corrections: - Send gateway keys as `Authorization: Bearer <key>` instead of the `api-key` header, across the labs, notebooks, scripts, samples, and the coding-agent plugin. - Request Entra tokens for `https://ai.gateway.azure.com` (scope `https://ai.gateway.azure.com/Data.All`), not `https://azure-api.net/aigateway`. - Remove the companion connector gateway: creating a gateway no longer creates one, and connectors come from a Connector Namespace that you create in Azure and import. - Regenerate the affected diagrams, recapture two portal screenshots, and patch the lab 01 walkthrough video's "what provisioning creates" and "automate" scenes, narration, and captions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
Take main's v4 coding-agent plugin (commands/aigateway, use-ai-gateway SKILL.md, build.md), which already uses Authorization: Bearer and the ai.gateway.azure.com audience, and drop the superseded commands/ai-gateway/build.toml. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
- Install aigateway@azure and run /aigateway:discover and /aigateway:build: the plugin was renamed from ai-gateway, and the old name now fails. - Describe model aliases with their operations, the MCP handshake that lists tools, Entra-first credentials, and build's approval before a call that costs tokens. - Add Go keyless roles and scopes and a "Manage the gateway from your agent" section with /aigateway:manage. - Notebook: new plugin name, and the build prompt approves one model call and installs dependencies with the kernel's Python. Ran end to end on a live gateway with Copilot CLI 1.0.110. - Troubleshooting: the renamed plugin, unverified tools, and no model call. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
…pin --model opus - Step 2 records what already exists once, before it deploys, so a rerun no longer claims the provider, models, aliases, key, or role that the first run created, and cleanup still deletes them. Steps 4 and 7 keep the first run's record of the practice project and the MCP server the same way. - Step 2 snapshots the policies of pre-existing aliases before the template replaces them, and cleanup restores that snapshot instead of the lab's post-deploy policies (now called baseline). - The role ownership is decided once, and the new assignment is polled for, because role assignment reads can lag for a minute or more. - The quick question and the Opus budget probe pass --model opus, so a model saved with /model or ANTHROPIC_MODEL can't bypass the Opus budget. The README and TROUBLESHOOTING explain it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
…7: align with the updated plugin - Lab 25: record the backends, routing and policies of existing aliases and put them back at clean up; set_policies keeps an alias's other properties; the template outputs the Foundry User assignment ID, so clean up deletes it even when the list hasn't caught up. - Releases tool: retry network errors, 429 and 5xx, then fail, so a lost docs chunk never passes for an empty one. - Lab 17: build uses an existing credential, never reads or writes keys, integrates into the existing project and verifies one request; no GitHub Copilot SDK scaffold. Verified live with the plugin on main. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
- claude-code.bicep: new createProvider parameter. When the gateway already has the account's provider, the template keeps it, with its authentication, and only adds the models under it, so a provider on a user-assigned identity keeps working after Clean up deletes the lab's Foundry User assignment. - Notebook: cell 7 passes createProvider from its record; cell 6 explains it. - README: the Bicep track detects the provider and passes createProvider. The Azure CLI Clean up deletes the three Claude models instead of the provider, and deletes the provider only when it has no models left. Verified live on a throwaway gateway, in Bash, PowerShell and the notebook, with a provider on a user-assigned identity that has another model, and without one. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because redeploying existing model registrations can remove token limits and cost controls, leaving shared aliases affected even after cleanup.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
- Resolve the root README (take main's layout, labs badge 27) and lab 16's requirements.txt (keep the newer certifi 2026.10.23 pin). - Lab 25: import the Claude deployments with `model-provider import`, because from CLI 1.0.0b30 `model-provider create --foundry-resource-id` no longer imports them. Note the 1.0.0b30 minimum, with a troubleshooting row for the error that older versions print. - Lab 17: describe the migrate and feedback commands as they work now; the feedback skill anonymizes a session summary and no longer creates a ZIP. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d05b6670-abba-4799-9d8e-3b2580e7bf94
Paul Yuknewicz (paulyuk)
approved these changes
Nov 16, 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.


Follow-up to #25, which merged before this commit was pushed.
What's new
Lab 25, "Use your gateway's models and tools in Claude Code": connect Claude Code to Claude models (
claude-opus-5-5, plus Sonnet and Haiku) and MCP tools through an Azure AI Gateway, then govern it with token limits and cost budgets.labs/25-claude-code/README.md: the guide, with Portal, Azure CLI, Bicep, and code tracks.labs/25-claude-code/25-claude-code.ipynb: merges the rate-limit and cost-limit demos into the standard lab structure, with branded output. Committed without outputs.labs/25-claude-code/infra/claude-code.bicep: the infrastructure for the lab.labs/assets/diagrams/claude-code.svgand theclaudeCodediagram inlabs/tools/diagrams/set-c.mjs.labs/TROUBLESHOOTING.md: a lab 25 section with the real error messages.labs/catalog.json,labs/README.md, the rootREADME.md(27 labs),AUTHORING.md, and the agent skill.Findings documented in the lab
ANTHROPIC_AUTH_TOKEN.ANTHROPIC_API_KEYsends it asx-api-key, which the gateway rejects with401.--fallback-modeldoesn't cover a403, so the lab switches with/model sonnet.apiKeyHelperthat runsaz account get-access-token --scope https://ai.gateway.azure.com/Data.All.Product-team corrections (all labs)
Three corrections from the AI Gateway product team, applied to every lab, notebook, script, Bicep sample, diagram, and
troubleshooting entry, plus
AGENTS.md,AUTHORING.md, and the labs agent skill:Authorization: Bearer <key>, not theapi-keyheader. Verified live: the Bearer key andapi-keyboth return200today,x-api-keyreturns401, and sending both headers returns400. The labs nowfollow the docs and keep a warning about sending both.
ai.gateway.azure.com, nothttps://azure-api.net/aigateway. Users request thescope
https://ai.gateway.azure.com/Data.All, and managed identities request the resourcehttps://ai.gateway.azure.com. Verified live: the token is v2.0 with theData.Allscope. The old audiencestill works today.
connector, you create a Connector Namespace in Azure and import its MCP endpoint. The labs' setup and cleanup
steps no longer include a connector gateway.
Media updated to match:
architecture,claude-code,create-gateway,github-copilot-byok,identity-boundaries,mcp-federation, andquickstart.copilot-mcp-06-cli-add.webpandquickstart-13-code.webp.shows the managed identity instead of the connector, and the automate scene shows
az aigateway createandinfra/gateway.bicep. Only the two changed segments were re-encoded; the rest of the video is unchanged. Thematching caption is updated.
The coding-agent plugin at the root is unchanged in this PR:
main's v4 plugin (#32, #39) already uses Bearer andthe new audience, so the merge kept
main's version.Lab 17 for the v4
aigatewaypluginaigateway:install ai-gateway@azurefails withPlugin "ai-gateway" not found in marketplace "azure". Available plugins: aigateway. The lab, notebook, and uninstall steps useaigateway@azureand/aigateway:*..envonly with approval./aigateway:manage, read-only example), and roles and scopes in Go keyless.Also
Fixed the tracks label on lab pages, which overflowed its border on phones (
labs/site/css/04-catalog-lab.css). It affected every lab.Fixed the two Dependabot alerts on
main, in lab 16's hosted agent lockfile (labs/16-foundry-hosted-agent/infra/src/gateway-agent/requirements.txt). Both packages come in through other dependencies:certifi2026.7.22 → 2026.10.23 (critical: bundled emSign root certificates whose intermediate CA keys were compromised).oauthlib4.0.0 → 4.0.1 (high: device workflow secret disclosure). Pinned by hand: the Microsoft package feed proxy doesn't serve 4.0.1 yet, souv pip compilecan't resolve it here. Its metadata is compatible, and Foundry builds the agent from PyPI.Validation
max_tokens.npm run checkfinishes with 0 warnings after mergingmain.pass syntax checks. Not checked: the
.ps1scripts (no PowerShell here) and the .NET sample (not compiled).npm run releases -- --checknow exits with 1: the product releases of October 28, November 6, and November 9,2026 aren't covered by the labs yet. They're left for a follow-up PR.