Skip to content

Default labs 16-33 to Entra ID and asset-scoped runtime access - #78

Open
Paul Yuknewicz (paulyuk) wants to merge 2 commits into
paulyuk-lab-catalog-identity-migrationfrom
paulyuk-lab-identity-16-33
Open

Paul Yuknewicz (paulyuk) wants to merge 2 commits into
paulyuk-lab-catalog-identity-migrationfrom
paulyuk-lab-identity-16-33

Conversation

@paulyuk

@paulyuk Paul Yuknewicz (paulyuk) commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 2ee4f5526f0b49ad6b288ffe04a569df490e3644

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Scoped runtime grants and refreshing SDK authentication have focused regression coverage; lab 23 (22) and lab 31 (1) helper tests pass in clean environments built only from each lab's requirements file.
↑ Strict labs build, plugin check, Bicep build, Terraform fmt and validate, notebook compile and Bash/PowerShell syntax gates pass on this revision.
↑ Live authorization boundaries, three streaming callers, router objectives and model-pool assertions passed; temporary resources were removed and Foundry accounts purged.
↓ Private-network managed identity, hosted/Foundry exchanges, full enterprise/tool smoke, embeddings/RAG and the external TypeSafe backend were not exercised live. Existing portal screenshots remain explicitly labeled as older captures.

Problem and solution

Several labs still create runtime keys automatically or teach callers to capture a key or access token. That conflicts with the Entra default and gives callers more access than the aliases and tool servers they actually use.

Make Entra ID the default throughout labs 16-33. Grant AI Gateway Models User only on each exercised alias and AI Gateway Tools User only on each exercised tool server. Keep local callers, hosted agents, Foundry projects and deployment smoke identities distinct. Preserve the existing Entra paths from #75, including labs 20 and 33.

Depends on #77 and targets paulyuk-lab-catalog-identity-migration.

Changes

  • Remove automatic keys from default Bicep and Terraform deployments. Add typed runtime principals and asset-scoped assignments, including the private container identity, enterprise smoke identity and Foundry project.
  • Refresh delegated SDK tokens through the shared provider. Local Azure CLI callers explicitly request Data.All; app-only and managed identities use .default. Avoid AzureCliCredential translating the delegated scope to --resource.
  • Convert remaining notebooks, streaming, embeddings/RAG, hooks and TypeSafe callers. TypeSafe sends one refreshed Bearer credential and removes its SDK-generated api-key header. Preserve outbound hook and backend authentication.
  • Update owned instructions, environment examples, generated navigation and the two authorized diagrams. Retain the routing, streaming, affinity and failover exercises.

Canonical local-user commands

Use the lab's RG, GATEWAY and ALIAS. Assign only the aliases that caller exercises. These commands do not print the token.

GATEWAY_ID="$(az aigateway show -g "$RG" -n "$GATEWAY" --query id -o tsv)"
CALLER_ID="$(az ad signed-in-user show --query id -o tsv)"
az role assignment create --assignee-object-id "$CALLER_ID" --assignee-principal-type User \
  --role a6b68e3d-a1f0-4c60-8678-237c050cf4ea \
  --scope "$GATEWAY_ID/workspaces/default/aliases/$ALIAS" -o none
export AI_GATEWAY_TOKEN="$(az account get-access-token \
  --scope https://ai.gateway.azure.com/Data.All --query accessToken -o tsv)"
$GATEWAY_ID = az aigateway show -g $RG -n $GATEWAY --query id -o tsv
if ($LASTEXITCODE -ne 0) { throw 'Could not read the gateway ID.' }
$CALLER_ID = az ad signed-in-user show --query id -o tsv
if ($LASTEXITCODE -ne 0) { throw 'Could not read the caller ID.' }
az role assignment create --assignee-object-id $CALLER_ID --assignee-principal-type User `
  --role a6b68e3d-a1f0-4c60-8678-237c050cf4ea `
  --scope "$GATEWAY_ID/workspaces/default/aliases/$ALIAS" -o none
if ($LASTEXITCODE -ne 0) { throw 'Runtime role assignment failed.' }
$env:AI_GATEWAY_TOKEN = az account get-access-token `
  --scope https://ai.gateway.azure.com/Data.All --query accessToken -o tsv
if ($LASTEXITCODE -ne 0) { throw 'Could not acquire a runtime token.' }

For an MCP caller, use Tools User (dce03f8d-857f-4e40-a90d-67770fa6ecd2) on <gateway-id>/workspaces/default/toolServers/<server> instead. Never substitute a workspace-wide grant. SDK samples acquire refreshed credentials per request rather than retaining the raw-command token.

Exceptions and observed behavior

  • Labs 24 and 25 remain dedicated key-client exercises. A gateway Owner must enable key-based access and acknowledge the risk first. Initial deployments create no key. Lab 24 also documents the supported Copilot SDK token-provider alternative. No Claude models were run.
  • Model Router rejects GPT-6.1-sol as a selector. Lab 28 uses supported GPT-6-sol version 2026-09-22. Actual Balanced, Cost and caller Quality batches all selected GPT-5-mini. The examples now record those results, verify objective headers and configured pool membership, and prove GPT-6-sol reachability with a single-model override instead of promising a particular split. Older GPT-5.5 screenshots retain accurate historical captions.
  • No unsupported gateway disableLocalAuth property or risk-acknowledgment CLI flag is introduced.

Validation

Local gates passed: labs sync/build/strict check with zero warnings, plugin checker, changed Bicep and enterprise parameter compilation, all 14 changed Terraform roots formatted and validated, helper/runtime-auth tests, Python checks, TypeScript type-check, eight notebook JSON/code/output checks, Bash and PowerShell syntax, and whitespace checks.

Live isolated verification passed: allowed alias 200, ungranted alias 403, unauthenticated 401; Bash, Python and TypeScript streaming; Terraform apply and a zero-change plan; Balanced/Cost/Quality requests and objective headers; both single-model pools and invalid-selector rejection. All verification resource groups were removed and Foundry accounts purged. The unexercised paths are listed in the assessment above. No local browser tests were run. The final commit is personally signed and GitHub reports its signature as verified.

Scope runtime roles to aliases and tool servers, refresh delegated SDK tokens, and keep key-only clients behind explicit Owner enablement. Align model-router examples with supported models and observed routing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…requirements

The samples import labs/shared/utils.py for runtime_token_provider, which
needs azure-identity and requests. A fresh environment that installs only
infra/requirements.txt failed with ModuleNotFoundError.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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