Skip to content

Default APIM migration to Entra and gate runtime key opt-in - #76

Open
Paul Yuknewicz (paulyuk) wants to merge 3 commits into
mainfrom
paulyuk-migrate-master-to-identity
Open

Paul Yuknewicz (paulyuk) wants to merge 3 commits into
mainfrom
paulyuk-migrate-master-to-identity

Conversation

@paulyuk

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

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: c37a6ed12b3842cb84b86ff9cad0c98afc0336c5

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Python 3.10 and 3.13 suites pass; identity defaults create no keys, master is rejected, and key opt-in stops before all phase writes without Owner acknowledgment.
↑ Rehearsal, acknowledged execution, prerequisite removal, and pinned-wheel surface compatibility are covered.
↓ No live gateway or caller cutover exercised; Owner acknowledgment is manual and can become stale.
Diagnosis confidence 9.5/10 ↑ Regression tests reproduced master-key creation and misleading choice ordering.
↑ New regressions reproduced key-phase writes without the required Owner confirmation.
Evidence fit 8/10 ↑ Entra-first defaults and the key opt-in gate align with the affirmed gateway-wide runtime access contract.
↓ The reported live target was not exercised; automatic setting detection is unavailable in the current API definition and pinned CLI.

Default migration path

Use Microsoft Entra ID for runtime callers. The default migration creates no API keys: accept entra-rbac, grant each caller runtime access to its required models, aliases, or MCP servers, and switch the caller to Entra tokens.

Key-based access is a gateway-wide setting, not a kind of API key. Under the Phase 2 runtime access contract, properties.disableLocalAuth defaults to true for new gateways, while pre-Phase 2 gateways initialize to false. Only a gateway Owner can change it. Enabling requires static-key risk acknowledgment and is subject to Azure Policy. These are contract semantics, not a claim that rollout is complete or that the current API/CLI exposes the setting. Migration does not toggle the target's setting. Entra is the expected path for both new and existing gateways.

The planner already proposed entra-rbac, but listed keys first and gave the choices no consequences. It now lists Entra first and states the no-key default in the choice, rationale, caller prerequisite, and operator documentation. Tests cover both the initial proposal and acceptance for ordinary, master-only, and mixed subscription inventories.

The operator supplies each caller's Entra object ID, principal type, and least-privilege model/tool scopes through prereq:caller-rbac. Shared APIM credentials cannot identify their consumers. Apply does not discover those identities or create their role assignments. Keep callers on APIM until their identity mapping, role grants, token cutover, and runtime checks are complete.

Run every configuration phase in order, including keys, which creates no keys on the default path. No skip or journal override is needed. Configuration completion does not acknowledge the caller prerequisite or prove runtime access.

Operator commands

Inspect item:access/subscriptions, accept the entra-rbac proposal by setting status to adapted and decision to entra-rbac, then regenerate the plan. Replace the placeholders below before running the role commands.

migrate-apim summary plan.json --item access/subscriptions
migrate-apim plan --inventory inventory.json -o plan.json
migrate-apim apply --plan plan.json --inventory inventory.json --preflight

# Repeat this rehearsal/execute pair for every configuration phase, in order.
migrate-apim apply --plan plan.json --inventory inventory.json --next-phase
migrate-apim apply --plan plan.json --inventory inventory.json --next-phase --execute

# After the target assets exist, grant only the roles and scopes each caller needs.
az role assignment create --role 'AI Gateway Models User' \
  --assignee-object-id <caller-object-id> --assignee-principal-type <principal-type> \
  --scope <model-or-alias-resource-id>
az role assignment create --role 'AI Gateway Tools User' \
  --assignee-object-id <caller-object-id> --assignee-principal-type <principal-type> \
  --scope <tool-server-resource-id>

# Only after caller token cutover and allowed/denied runtime checks:
migrate-apim apply --plan plan.json --inventory inventory.json \
  --acknowledge prereq:caller-rbac

Use the Entra object ID, not application/client ID. Principal type is User, Group, or ServicePrincipal, including ServicePrincipal for managed identities. An alias scope is <gateway-resource-id>/workspaces/default/aliases/<alias-name>; an MCP-server scope is <gateway-resource-id>/workspaces/default/toolServers/<server-name>.

Explicit opt-in for non-Entra clients

Choose gateway-key-per-consumer only for clients that cannot use Entra. It creates fresh gateway-wide keys for ordinary APIM subscriptions, never the built-in master subscription. Distribute the replacement credentials and change those clients separately; no APIM key value is imported. Migrated clients use Authorization: Bearer <key> or api-key: <key>, never x-api-key. Each named key follows the single-secret contract, with no secondary key. Backend provider credentials are a separate contract.

Stop before executing keys until a gateway Owner confirms that key-based access is enabled, with the required risk acknowledgment and Azure Policy compliance. The plan adds prereq:key-based-access; execution refuses the entire keys phase before any step without its acknowledgment, including telemetry writes in that phase. Earlier configuration phases can provision the target first. Rehearsal remains available.

# Only after the Owner confirms that the target permits key-based access:
migrate-apim apply --plan plan.json --inventory inventory.json \
  --acknowledge prereq:key-based-access

# Continue the normal rehearsal/execute sequence; do not skip phases.

When access is disabled under Phase 2, key metadata GET and DELETE remain available, but authorized mutations and listSecrets fail with 409 LocalAuthDisabled; runtime key requests fail with 401. Metadata read-back does not prove that keys work. If the state cannot be established, access is disabled, or policy forbids it, stop key opt-in and re-plan for Entra. Acknowledgment records Owner confirmation, not a live check, and can become stale. Preflight continues to report keyAccessUnverified after acknowledgment.

The original defect included master in the key option and attempted to create it when absent. This PR excludes it from target generation and rejects older plans that still contain it during preflight and in the key builder. Re-plan older artifacts. Entra is the default, so migration never recreates that shared all-access credential. A service-wide scope or an "All access" display name does not make an ordinary subscription master.

Follow-up: automatic key-access detection

The current AIGateway API definition and pinned CLI do not expose disableLocalAuth. This change deliberately adds no speculative property read, API version, CLI flag, or automatic toggle. Add live state detection when a supported API/CLI exposes the setting, and replace the manual unknown-state boundary with a pre-write check. Until then, the gate requires Owner confirmation through a supported product control; inability to establish the state means using Entra instead.

Validation and related work

  • Python 3.10 and 3.13: 1,063 passed, 1 skipped on each.
  • Workflow schema-validator check and capability compilation with published release tags passed. python -m migrate_apim compile --strict: zero errors and warnings.
  • Pinned b31 wheel: SHA-256 verified, installed in isolated Azure config/extension directories, help-parser self-test passed, surface re-exported, strict compilation against that export passed, and no snapshot drift.
  • git diff --check passed. No CLI core or extension implementation changes, so azdev extension gates do not apply.
  • Commits use the personal paulyuk 1Password key; GitHub reports their signatures as verified with reason valid.
  • Related docs work: Use identity-first runtime auth for default-disabled key access #75. The current patches apply cleanly in either order. This PR owns the separate keys-behavior section and directly related architecture/schema text.

Never recreate APIM's built-in master subscription as a gateway key. Direct its callers to the existing manual Entra RBAC prerequisite with explicit object IDs and least-privilege model/tool scopes. Reject master targets in older plans and keep caller cutover separate from configuration completion.

Deliberately update the golden plan for the changed subscription rationale and caller-RBAC guidance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
List Entra RBAC first with explicit no-key behavior. Describe per-consumer keys only as an opt-in for non-Entra clients. Lead caller prerequisites and documentation with identities and least-privilege model/tool scopes, while retaining normal phase completion and master-key guards.

Deliberately update the golden plan for the normative access choices and prerequisite wording.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@paulyuk Paul Yuknewicz (paulyuk) changed the title Handle disabled API built-in keys during APIM migration Default APIM migration to Entra with API built-in keys disabled Dec 3, 2026
Keep Entra as the default. Align key opt-in prerequisites and client guidance with the gateway-wide Phase 2 runtime access contract, without claiming unsupported disableLocalAuth detection. Update the golden plan to match the clarified access choices.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@paulyuk Paul Yuknewicz (paulyuk) changed the title Default APIM migration to Entra with API built-in keys disabled Default APIM migration to Entra and gate runtime key opt-in Dec 3, 2026

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