Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement security policies for back-end API protection by using API Management

A worked example

Single answer

Contoso Retail publishes a partner API through Azure API Management. The partner product has the subscription requirement turned off: partners do not send subscription keys and are authenticated only by a validate-azure-ad-token policy. Partners call the gateway directly from their own public IP addresses, not through a shared proxy.

To protect the backend from traffic spikes, you must add an inbound policy that meets these requirements:

  • Configure a call-rate limit of 30 calls per 60 seconds for each source IP address, regardless of how many tokens it uses.
  • Return HTTP 429 Too Many Requests when the rate limit is exceeded.

Which policy statement should you add to the inbound section of the partner product?

Choose one answer
Why

Use rate-limit-by-key with the request IP address as its counter key to configure the required per-IP call rate without subscription keys. This rate-limiting policy returns HTTP 429 when its limit is exceeded. The subscription-based policies do not establish per-IP counters, and quota returns HTTP 403. Using the Authorization header as the key would separate counters by token instead of IP address.

  • Not correct: <rate-limit-by-key calls="30" renewal-period="60" counter-key="@(context.Request.Headers.GetValueOrDefault("Authorization",""))" />. This counter key is the bearer token value. A single IP address using several tokens gets separate counters instead of sharing one IP-based counter.
  • Not correct: <rate-limit calls="30" renewal-period="60" />. The rate-limit policy counts calls per subscription. Partners here use no subscription keys, and this policy does not establish a separate counter for each source IP.
  • Not correct: <quota calls="30" renewal-period="60" />. The quota policy tracks usage per subscription and returns 403 Forbidden when exhausted. It does not provide the required IP-based throttle or HTTP 429 response.
  • Correct: <rate-limit-by-key calls="30" renewal-period="60" counter-key="@(context.Request.IpAddress)" />. rate-limit-by-key counts calls against a custom key, here the source IP address. It works without subscription keys and configures a rate of 30 calls per 60 seconds for each IP.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free