Repository navigation
Make labs 00-15 Entra-first with alias-scoped runtime roles - #77
Open
Paul Yuknewicz (paulyuk) wants to merge 6 commits into
Open
Paul Yuknewicz (paulyuk) wants to merge 6 commits into
Paul Yuknewicz (paulyuk) wants to merge 6 commits into
Conversation
Notebooks call AI Gateway with the signed-in identity instead of a runtime key. Lab.runtime_token() returns a cached, refreshed delegated token for https://ai.gateway.azure.com/Data.All. Lab.authorize(alias=...) or Lab.authorize(server=...) grants AI Gateway Models User on one alias or AI Gateway Tools User on one MCP server when the assignment is missing. mcp_session and mcp_request accept a token provider so long sessions refresh. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Lab 02 publishes a Foundry model and calls it with Microsoft Entra ID and an alias-scoped AI Gateway Models User grant in every track: portal, CLI, curl scripts, Python, TypeScript, .NET, Bicep, Terraform, and the notebook. publish-model.bicep takes createApiKey, default false, and returns an empty apiKeyName unless a dedicated key exercise passes true. The Terraform track has the matching create_api_key variable with a moved block for existing state. Lab 18 imports this module and no longer gets a runtime key. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Labs 18-31 now acquire a runtime token instead of creating a key, read their outputs without a key, and drop the API-key client qualifiers from lab 26 and lab 31 steps. Update the shared troubleshooting step references to match. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Labs 00-15 now call AI Gateway with Microsoft Entra tokens and AI Gateway Models User on each called alias (Tools User on each MCP server). Bicep, Terraform, azd, CLI and REST tracks, SDK samples, notebooks and Bash and PowerShell helpers create no runtime keys. Key and per-key budget and telemetry comparisons move to lab 10, the dedicated key lab. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AzureCliCredential turns the Data.All scope into `az account get-access-token --resource`, which returns the wrong token. runtime_token() and runtime_token_provider() in labs/shared/utils.py call `az account get-access-token --scope` directly, cache the token and refresh it 5 minutes before expiry, with no Lab, gateway discovery or ARM access. Lab.runtime_token delegates to them. TROUBLESHOOTING gets the labs 03-15 Entra rows, a note on the --resource behavior, and lab 28's move from GPT-5.5 to gpt-6-sol, including the Model Router selector error for gpt-6.1-sol. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Live tests chose gpt-5-mini for every prompt under Balanced, Cost and Quality, so the served model doesn't show which objective applied. The lab 28 rows and the labs skill now point to x-ms-model-router-mode for the objective, and to auto_model_selection.models to reach gpt-6-sol. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
3c33b3536ab0144841b9a49c19dc4e1634b4a7a1↑ Lab 06 Terraform passed apply, a no-change plan, an Entra call returning 200, and destroy.
↑ Bicep builds, Terraform fmt and validate, Bash and PowerShell parsing, notebook compile, plugin check and focused helper tests all pass locally.
↑ The delegated token helper was checked live and returned the gateway audience.
↑ Lab 28 troubleshooting now checks
x-ms-model-router-modefor the objective, matching live labs 16-33 tests where every objective chose gpt-5-mini.↓ No live auto-alias gateway was available here, so the header contract rests on those tests and the product docs.
↓ Labs other than 06 had static checks only, with no live deployment.
↓ The strict labs check shows 20 step-reference warnings until the labs 16-33 headings land.
↓ Portal steps were not checked in a browser.
Stacked on #75. Review and merge #75 first.
Problem
Labs 00-15 taught runtime API keys as the normal way to call AI Gateway, and several Bicep, Terraform and notebook paths created keys on their own. New gateways disable key-based access, so those paths stop working, and they teach the wrong default.
What changes
Labs 00-15 call the gateway with Microsoft Entra tokens and least-privilege runtime roles:
a6b68e3d-a1f0-4c60-8678-237c050cf4ea) on each alias the lab calls, never workspace-wide by default.dce03f8d-857f-4e40-a90d-67770fa6ecd2) on each MCP tool server the lab calls.publish-model.bicepand the shared modules create no runtime key unless a dedicated key lab setscreateApiKey.role-assignment.bicepnow defaults to alias scope.labs/shared/utils.pyaddsruntime_token()andruntime_token_provider(). They callaz account get-access-token --scope https://ai.gateway.azure.com/Data.Alldirectly and refresh the token before it expires.AzureCliCredentialturns that scope into--resource, which requests the wrong token.Lab.runtime_tokenuses the helper.gpt-6-solas the Model Router selector, becausegpt-6.1-solis rejected. Lab 28 troubleshooting checks the objective withx-ms-model-router-mode, because the served model doesn't show which objective applied.Common case
Bash:
PowerShell:
SDKs and managed identities use
DefaultAzureCredentialwithhttps://ai.gateway.azure.com/.default.Verification
Token limit is exceeded.Not converted
npm run checkreports 20 troubleshooting step-reference warnings for labs 18, 22, 26, 27 and 28. They come from lab steps that PR renames.AI_GATEWAY_UNAUTHORIZED_TOKEN.disableLocalAuthisn't in the AI Gateway API or theaz aigatewayCLI yet. The templates don't set it, and key enablement is written as a gateway Owner prerequisite.