Protecting Back-End APIs with API Management
This lesson explains how policies validate callers, limit use and authenticate to back ends.
Learning outcomes
After completing this lesson, you will be able to:
- Choose a token validation policy.
- Distinguish rate limits from quotas.
- Describe content validation.
- Explain how a gateway authenticates to a back end.
API Management as a security layer
An API exposed directly must handle authentication, rate limits and validation by itself. Azure API Management moves those concerns to a gateway, so that a back end receives only requests that have passed its checks. Requests pass through policies, which are XML statements run in sections: inbound, backend, outbound and on-error.
The OWASP API Security Top 10 lists common API risks, such as broken object-level authorization and unrestricted resource consumption. API Management helps with many of them, although it cannot fix a flaw in a back end's own authorization logic. The Defender for APIs plan adds discovery and threat detection, and Microsoft also suggests a WAF in front and DDoS Protection.
The following diagram shows the policy sections a request passes through.

Validating callers
Policies check who is calling. The following table describes the main ones.
| Policy | Purpose | Key point |
|---|---|---|
| validate-azure-ad-token | Validates a token issued by Microsoft Entra ID | The preferred policy for Entra tokens |
| validate-jwt | Validates any JSON web token | Use for other identity providers; a failure returns 401 by default |
| validate-client-certificate | Checks a client's certificate | For mutual TLS with callers |
| ip-filter | Allows or denies caller addresses | A coarse filter, to be used with identity |
| check-header | Requires a header with a given value | A simple check, not real authentication |
A subscription key identifies a client application, for tracking and throttling. It is not a strong proof of identity, since it is a shared secret, so a sensitive API should also demand a token. The following policy validates a Microsoft Entra token, and requires a specific audience and role claim.
<inbound>
<base />
<validate-azure-ad-token tenant-id="TENANT_ID">
<audiences><audience>api://orders</audience></audiences>
<required-claims>
<claim name="roles" match="any"><value>Orders.Read</value></claim>
</required-claims>
</validate-azure-ad-token>
</inbound>The validate-jwt defaults are strict: an expiration time and a signed token are required, and clock skew is zero.
Caller validation policies
Limiting use
Limits protect a back end against overload, and they make abuse more expensive. Candidates should know the differences among the following policies.
| Policy | Limits | Key by | Exceeded response |
|---|---|---|---|
| rate-limit | Calls in a short window | Subscription | 429 |
| rate-limit-by-key | Calls in a short window | Any expression, such as an IP address or claim | 429 |
| quota | Calls or bandwidth over a long period | Subscription | 403 |
| quota-by-key | Calls or bandwidth over a long period | Any expression | 403 |
| limit-concurrency | Simultaneous calls | A key | 429 |
A rate-limit policy applies only when an API is called with a subscription key, with a renewal period of up to 300 seconds. To limit callers by something else, such as a client address on a public API with no subscription, use rate-limit-by-key. Counts are tracked per gateway.
Which limit policy?
Validating content
Attackers send unexpected content to back ends. validate-content checks a request body against an API schema and size limit, validate-parameters checks query and path values, validate-headers checks response headers, validate-status-code checks response codes, and validate-graphql-request checks GraphQL. Each can run in a detection or prevention style, so that a team can observe first.
Outbound policies also matter. set-header can strip headers that reveal back-end technology, such as X-Powered-By, and cors controls which browser origins can call the API.
Authenticating to the back end
A gateway also needs to prove itself to the back end, and the back end should trust only the gateway. The options are as follows.
- authentication-managed-identity obtains a token with the gateway's managed identity, for a resource named in the
resourceattribute, and sets it as a Bearer token. Withoutclient-id, it uses the system-assigned identity. - Mutual TLS presents a client certificate to the back end, kept in Key Vault, from where it rotates automatically within four hours, or uploaded as a PFX file. With a Key Vault firewall, a system-assigned identity and the trusted services bypass are needed.
- Network isolation places the gateway in a virtual network, so that the back end allows only that subnet, or uses a private endpoint.
<backend>
<authentication-managed-identity resource="api://orders-backend" />
<base />
</backend>Anyone who can edit a policy can use the gateway's managed identity, so restrict who can edit policies, just as with Logic Apps.
Gateway to back end
Protecting an orders API
A public API issues Microsoft Entra tokens to customers' applications. The company must reject calls without a valid token and the Orders.Read role, limit each client to 60 calls a minute based on the client ID in the token, and stop the back end from being reached directly. No secret may be stored for the back-end connection. What policies and settings do you need?
Use validate-azure-ad-token with audience and role claims. Use rate-limit-by-key with a counter key based on the token's client ID, since plain rate-limit keys on subscriptions. Use authentication-managed-identity for the back end, and configure the back end, through Easy Auth or network rules, to accept only the gateway.
validate-jwt would work, but Microsoft recommends the Entra-specific policy for such tokens. A subscription key would not satisfy the requirement for role-based access. A mutual TLS certificate would store a credential, which the scenario wishes to avoid.
Which policy limits a public API's callers by client IP address with no subscription key?
Show answer
rate-limit-by-key, with a counter key based on the address.
Exam Tips
Remember for the exam
- Use validate-azure-ad-token for Entra tokens, and validate-jwt for others.
- rate-limit needs a subscription key; rate-limit-by-key does not.
- Rate limits return 429; quotas return 403.
- authentication-managed-identity avoids a stored back-end credential.