APIM Deployment and Debugging
APIM failures should be isolated by policy scope and authentication leg. Preserve the correlation identifier, status, API, operation, and deployment revision; do not capture bearer tokens or capability tokens as troubleshooting evidence.
Deployment order
- Deploy or verify backend OAuth and the expected audience.
- Provision the selected APIM UAMI and backend permission.
- Deploy required named values and fragments.
- Import the OpenAPI contract and associate the product.
- Apply API policy.
- Apply every operation policy.
- Apply API diagnostics.
- Run positive and negative tests.
- Reconcile OpenAPI operations with deployed operation policies.
Product policy changes (MFE) deploy from signet/infrastructure-shared and affect
every MFE BFF. Deploy them to Alpha and Beta first and run the MFE capability tests
for at least one BFF per shell before promotion.
A service deployment must not depend on manual policy edits in the Azure portal.
Failure isolation
| Symptom | Likely boundary | Checks |
|---|---|---|
401 before API policy | Global caller authentication | Header, scheme, signature, expiry, issuer, audience, required claims |
| Customer tenant rejected | Global tenant policy | Tenant claim, active onboarding state, validation dependency, cache state (30 minutes) |
401 on MFE route in Production only | Global audience list | MFE UI audience missing from the Production list |
403 on every MFE route | Product policy | Signet /v1/validations reachability (5-second timeout), APIM UAMI grant, capability token presence |
403 on one MFE route | Product policy | Path parameter naming, tenant or workspace outside capability scope, write gate for the HTTP method |
403 for one operation | Operation policy | Terraform map key, OpenAPI operationId, required Ion.* role, role assignment, template uses roles_csv |
429 | Product or API policy | Rate-limit key (oid, tid, IP), quota window, limit size |
| All operations hit wrong host | API policy | Backend base URL and environment variables |
| One operation hits wrong path | Operation policy | Rewrite template and unmatched parameters |
Backend 401 | APIM → backend authentication | APIM token audience, selected UAMI, backend OAuth configuration |
Backend 403 | Backend authorization | APIM principal/application role and backend authorization policy |
Backend sees unexpected caller in X-Authorization | Global header policy | Client-supplied header surviving exists-action="skip" (APIM-01) |
| Direct backend call succeeds anonymously | Backend platform authentication | Authentication enabled, unauthenticated action, excluded paths |
| Stale or cross-context response | Cache policy | Tenant/customer/capability variation, query/header variation, duration, invalidation |
| Missing trace | Diagnostic or fragment | Logger, API diagnostic, fragment inheritance, sampling, destination access |
| Policy deployment rejected | XML/template | XML escaping, valid section/scope, named values, template variables, <base /> |
| Gateway overload or timeout | Traffic/backend | Rate key, concurrency, backend latency, APIM capacity and autoscale, 120-second forwarding limit |
Distinguish the two token legs
Caller to APIM
Inspect only safe metadata: expected issuer category, expected audience category, tenant classification, whether the required claim exists, and authorization result. Do not paste or decode a production token into change records or logs.
APIM to backend
Verify the selected APIM identity, requested backend audience, backend OAuth allowed principals, and backend application role. A valid caller token does not prove that APIM can authenticate to the backend.
Safe tracing procedure
- Generate or capture
X-Transaction-Idfrom a controlled test request. - Identify the environment, API, operation, time window, and expected outcome.
- Find the APIM request/error trace by correlation ID.
- Find backend telemetry using the same correlation ID.
- Compare policy stage, response code, backend URL category, and authorization outcome without exposing headers or token payloads.
- Record the root cause, policy/deployment revision, and retest result.
APIM tracing can expose request and response content if policies are overly broad (APIM-03). Do not enable body or header capture as an ad hoc production debugging shortcut.
Required validation matrix
| Test | Expected result | Current state |
|---|---|---|
No Authorization header | 401 at APIM | Passes |
| Invalid signature or expired token | 401 at APIM | Passes |
| Wrong audience or issuer | 401 at APIM | Passes |
| Unknown or inactive customer tenant | Denied before backend | Passes |
| Valid token without operation role | 403 at operation policy | Passes where the template enforces roles_csv; fails for Signet (APIM-05) |
| Valid caller and role | Request reaches intended protected backend | Passes |
| MFE route with missing, expired, or out-of-scope capability | 403 at product policy | Passes |
| MFE route with Signet unavailable | 403 at product policy | Passes |
| APIM UAMI lacks backend grant | Backend authentication/authorization failure | Passes |
| Anonymous direct backend request | Rejected by platform OAuth | Passes |
Caller-supplied X-Authorization | Overwritten by APIM | Fails (APIM-01) |
Request without Front Door X-Azure-FDID | 403 at APIM | Fails except on Pigeon Twilio (APIM-02) |
| Same cache inputs in different tenants | No cross-tenant cache reuse | Test per cached operation |
| Public synthetic health | Successful without exposing backend state | Passes |
| Authenticated health without role | Denied | Passes |
The “Current state” column is derived from policy inspection, not from a recorded test run. Record actual results for each environment.
Rollback
Roll back the version-controlled API, operation, or product policy and redeploy it. If the change introduced a new route or role, remove the route or assignment and verify denial. Do not fix production by retaining an untracked portal edit.
Policy rollback and OpenAPI rollback may need to be coordinated when operation IDs or paths changed. Preserve backward compatibility until callers have moved or remove the route deliberately.
Emergency containment
Depending on the incident, the owner can:
- block or remove one operation;
- remove an application-role assignment;
- disable an API or product association;
- remove the APIM identity’s backend permission;
- change backend OAuth allowed principals;
- stop the backend workload;
- restrict edge or network access; or
- disable customer tenant activation.
Account for APIM (including the 30-minute tenant cache), Entra token, and application caches. When revocation cannot wait for expiry, combine identity revocation with route, workload, or network containment. Do not weaken authentication or capability checks to restore traffic.
Retirement
- Notify and migrate callers.
- Remove edge routes and APIM operations.
- Remove operation and API policies.
- Remove API/product association and imported contract.
- Remove API diagnostics and logger resources used only by the API.
- Remove APIM backend role grants and unused named values.
- Disable and retire the backend according to its service lifecycle.
- Verify the gateway path and direct backend path are denied.
- Retain safe audit and change evidence according to policy.