A door has two sides
The courier has a valid subscription key and asks for another customer’s order. The gateway knows which subscription was used, but that does not establish whose order the caller may read. Ada checks the access token’s issuer, audience and permissions, then makes sure the backend enforces the order-level rule. The denied request is the point of this class: having one valid key does not satisfy every check along the route.
The gateway has two trust boundaries. At the front, APIM checks the caller’s credential and decides which operations it may use. At the back, the backend checks APIM’s credential and the network path. A signed bearer token and a client certificate solve different problems; neither automatically authorizes an order or payment. The right combination depends on the caller, data, key storage and threat model.
- Subscription key
- A bearer credential identifying an APIM subscription. It supports separate counters and suspension, but does not prove which person or app holds it.
- OAuth2 / JWT
- An access token issued by an identity provider. Configure validate-jwt to check the intended issuer, audience, expiry and required claims. A stolen bearer token can still be replayed until it expires or is otherwise blocked.
- Client certificate / mTLS
- A certificate presented by a client over TLS. APIM must request and validate it. The private key is not sent in the handshake, but it can be copied if poorly stored.
- Managed identity
- An Azure-managed identity APIM can use to obtain a backend access token without storing a long-lived password in policy. The token still needs careful forwarding and validation.
- Named Values / Key Vault
- Named values store configuration or reference Key Vault secrets. A vault reference avoids embedding the secret in policy text, but access permissions and refresh behavior still need review.
The front door — from a key to a signed token
A caller can send a subscription key in the Ocp-Apim-Subscription-Key header. APIM can associate it with a subscription for access and usage counting. The key does not carry a signed statement about the caller, and it does not expire by itself. Protect it like a credential and combine it with application authentication when the API’s risk warrants it.
For partner operations, require an OAuth2 access token issued for this API. APIM’s validate-jwt policy can check the signature, expiry, issuer, audience and a required role or scope when you configure those checks. A valid token identifies a principal or application represented by its claims; the backend must still authorize the requested action. A stolen bearer token may be replayed during its validity period, so keep its lifetime and storage appropriate to the risk.
This is an illustrative inbound policy fragment. Replace the tenant, audience and role with values from your own app registration, then test valid, expired, wrong-audience and wrong-role tokens:
<!-- inbound: reject anything without a valid Entra token -->
<validate-jwt header-name="Authorization" require-scheme="Bearer"
failed-validation-httpcode="401"
failed-validation-error-message="Unauthorized">
<openid-config url="https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration" />
<audiences><audience>api://campux-catalog</audience></audiences>
<required-claims>
<claim name="roles" match="any"><value>Catalog.Read</value></claim>
</required-claims>
</validate-jwt>
The gateway now checks more than possession of a subscription key: it validates the access token’s origin, intended API and required claim. A signed token is still a bearer credential. Keep authorization in the backend too, especially for orders, personal data or money.
Validate the credential, then authorize the action.
Play it through
Match four risks to the control that addresses each: an exposed subscription key, an invalid token, a client without the required certificate and a password stored in policy. Then check what still needs backend authorization.
This part uses a no-cost simulation. A production security policy also needs real issuer and audience values, valid test credentials, backend authorization and network checks. The game teaches which control addresses which risk; it cannot verify a deployed gateway.
Client certificates and mTLS
For a machine-to-machine integration, mTLS can authenticate the client connection using a certificate in addition to the server’s TLS certificate. The client proves possession of its private key without sending that key in the handshake. It is not theft-proof: a private key stored in an exportable file or compromised host can be copied. Plan issuance, storage, rotation and revocation with the partner.
APIM must request the client certificate and validate the certificate properties your design relies on. For Basic v2, Standard v2, Premium v2 and Consumption, Microsoft calls the hostname setting Request client certificate; classic tiers use Negotiate client certificate for the documented HTTP/2 path.1 Verify the trusted issuer, expected subject or thumbprint, expiry and revocation requirements. Certificate validation authenticates a connection; authorize the payment operation separately.
These controls are complementary, not a universal ranking. A subscription key helps with APIM attribution. An access token carries claims for authorization. A client certificate binds a connection to a private key. A payment processor may need mTLS and a token or other transaction authorization; a public catalog still needs abuse and data-risk review.
Authenticate APIM to the backend
Now secure the route from APIM to the backend. When the backend supports Microsoft Entra authentication, APIM can use a managed identity to obtain a short-lived access token for that backend.2 This removes a long-lived backend password from policy. The backend must validate the token’s audience and identity and authorize only the intended operations. Restrict direct network access as Part G explains; identity alone does not make APIM the only path.
<!-- inbound: get a token for the backend as APIM's own identity -->
<authentication-managed-identity resource="api://campux-orders"
output-token-variable-name="msi-token" />
<set-header name="Authorization" exists-action="override">
<value>@("Bearer " + (string)context.Variables["msi-token"])</value>
</set-header>
The backend should validate the token and allow only the APIM identity intended for that operation. The managed identity removes a stored password, but the access token is still a bearer credential and policy editors can expose or misroute it. Review who can edit APIM policies and where the token is forwarded.
Some backends still require a secret. APIM Named Values can hold plain configuration, an encrypted secret, or a Key Vault secret reference used in policy as {{name}}. Prefer a vault reference for a secret and give APIM’s identity only the access it needs. Microsoft says a changed vault secret can take up to four hours to refresh in APIM, and a versioned reference does not auto-refresh. Test rotation and restrict policy-edit and tracing permissions; a reference keeps the literal secret out of policy text, not beyond reach of every administrator.
Different callers, distinct controls
In this fictional case, Campux uses separate subscription keys to attribute partner catalog calls, then requires an Entra access token with the intended audience and an Orders.Write role for order changes. The orders backend also checks authorization for the requested order. A payment processor presents a client certificate to authenticate its connection, and payment operations require separate authorization and transaction checks. Certificate key storage and rotation are part of the design.
For backends that support Entra, APIM requests tokens with its managed identity and the backends validate that identity and audience. Network rules limit bypass. A legacy shipping key is stored in Key Vault and referenced through a Named Value; Campux tests refresh and restricts who can edit or trace policies. No one copies the secret into source control.
Both faces locked
The caller-to-APIM and APIM-to-backend boundaries now have explicit checks. Subscription keys support attribution; access tokens or certificates can authenticate a caller when correctly validated; managed identity can authenticate APIM to an Entra-aware backend. None of those alone authorizes every operation or blocks a network route around APIM. Part G tests the network path.
The password in the pull request
A pull request includes a backend API key in policy XML. Stop the merge, treat the exposed key as compromised and rotate it; deleting the line does not erase copies in Git history or review systems. If the backend supports Entra, use APIM’s managed identity and validate it at the backend. Otherwise store the replacement in Key Vault, reference it through a Named Value, restrict policy-edit access and test secret refresh. The choice depends on what the backend supports; neither path is a two-line security fix.
Continue with a supplied build
Follow the same fictional catalogue through this track. The supplied contract and worked checks let you practise without an Azure estate; the optional import/mock path makes real gateway requests. Each step states what it proves and what it does not.
Examination
Four drills, then two situations. The situations have no marking scheme — write your answer before you reveal the reasoning, or the exercise is worthless. Nothing is stored; this is between you and the page.
A — select controls for each trust boundary. The catalog needs a data and abuse-risk review. Order writes need caller authentication and authorization for the requested operation. mTLS can authenticate a payment processor connection, while payment authorization remains separate. Certificates are not a universal strongest credential: private keys can be stolen if stored poorly, and a client certificate does not carry all transaction permissions. JWTs are also bearer credentials that can be replayed if stolen.
B — managed identity removes the stored backend password. APIM obtains an access token for the configured resource and forwards it in the Authorization header. The backend must validate the token’s audience and APIM identity. The token can still be exposed by careless policy edits, tracing or forwarding, so restrict those permissions. A Named Value marked secret still stores a long-lived password; C puts one in source; D forwards a subscription key the backend should not treat as its own authentication.
Signature, issuer/audience/expiry, and configured claims. These checks apply when the policy is configured with the correct OpenID endpoint, audience and required claims. They do not encrypt the request body or issue a token. A validated JWT is still a bearer credential; the backend should independently authorize sensitive actions and protect direct access.
# apim security checklist
1. validate-jwt on write operations: signature,
audience, issuer, expiry, required role.
2. Payment processor authenticates with a client
certificate (mTLS), thumbprint allow-listed.
3. Backend key stored inline in the inbound policy
XML so deploys are self-contained.
4. APIM uses a managed identity to read secrets
from Key Vault; no passwords in templates.
Line three. An inline backend key can enter source control and build artifacts. If it has already appeared in a pull request, treat it as exposed and rotate it. Store a replacement in Key Vault with a Named Value reference, or use managed identity if the backend supports it. Token expiry and client-certificate validation still matter, but neither alone authorizes a payment.
Acknowledge what the key does. A separate subscription key lets APIM attribute and limit calls made with it and suspend that subscription. It does not prove which application or person holds the key. If it leaks, an attacker can make calls attributed to that subscription.
Explain the order-write requirement. Require a short-lived access token for the intended API. Configure APIM to validate its signature, issuer, audience, expiry and a claim permitting order writes. The backend must still authorize the specific order change. A stolen bearer token can be replayed until it expires or another control blocks it.
Test the whole path. Check missing, expired, wrong-audience and wrong-role tokens, API-scoped subscription paths and direct backend reachability. Keep the subscription key for its separate APIM purpose; do not mistake either credential for complete transaction authorization.
Start with both boundaries. APIM validates the caller credential before forwarding, and the backend validates APIM’s credential. Test direct backend access as well; Part G’s network rules should restrict routes around the gateway.
Choose front-end controls by threat. Subscription keys help attribute calls. JWT validation can check issuer, audience, expiry and operation claims. mTLS can authenticate a machine connection, but requires private-key protection and certificate lifecycle management. None of them alone decides whether a payment or order change is authorized.
Secure the back end and secrets. Where supported, use APIM’s managed identity for a backend access token and validate that identity at the backend. For an unavoidable secret, reference Key Vault through a Named Value, restrict policy-edit and tracing permissions, and test rotation. Never place the literal secret in a policy or repository.
Five things worth carrying out of this part
- Check both boundaries: caller to APIM, then APIM to backend. Also restrict direct network paths to the backend.
- A subscription key identifies the subscription presented on a call; a stolen copy can be used by someone else.
- Configure JWT validation for issuer, audience, expiry and required claims. Use mTLS when the connection needs certificate-based authentication, with private-key and lifecycle controls.
- Managed identity removes a stored backend password when the backend supports Entra. Protect the resulting bearer token and have the backend validate it.
- For unavoidable secrets, prefer Key Vault references through Named Values. Restrict access and test rotation; never embed the literal secret in policy or source control.
- Microsoft documents client certificate settings by APIM tier. The gateway must request and validate the certificate; intermediate proxies may change what certificate reaches it. ↩
- The managed-identity policy forwards a bearer token, and Microsoft warns policy editors can expose or misroute it. Key Vault-backed Named Values refresh after a secret change, potentially taking up to four hours. Test both flows in the deployed environment. ↩
Separate subscription-key controls from token validation and application authorisation.
Play the lesson above to stamp this class.