Prevent Event Grid event loss when an Azure Function returns HTTP 400

AI-200 By islever Editorial Last updated

Develop event- and message-based AI solutions Develop and implement Azure Functions

Short answer

C Configure a dead-letter destination on the Event Grid subscription so events rejected with HTTP 400 by the Azure Function are retained in storage instead of being lost.

Question

You have an Event Grid subscription that triggers an Azure Function. You need to prevent loss of events in case the endpoint returns an HTTP 400 response. Which action should you perform?
  1. Implement optimistic batching.
  2. Implement asynchronous handshake validation.
  3. Configure a dead-letter destination. Correct Answer
  4. Configure a retry policy.

Key Takeaways

Azure Event Grid dead-letter destinations preserve events that cannot be delivered to an Azure Function, including rejected HTTP 400 responses. Configuring a dead-letter destination wins over a retry policy because retries alone do not provide a final retention path for undelivered events.

Expert Analysis

An HTTP 400 response can make delivery unsuccessful without ensuring that repeated delivery will eventually succeed. A dead-letter destination preserves events that cannot be delivered, so they remain available for investigation or later recovery instead of being discarded. A retry policy alone does not provide that final retention path.

HTTP 400 from an Azure Function is a deliberate rejection by the subscriber, not a transient transport failure. Event Grid's subscription delivery path has to decide what to do with an event the endpoint will not accept: keep attempting it, discard it, or place it somewhere durable. A retry policy only repeats the attempt, and if the function's validation or business logic is what produces the 400, the next attempt is likely to produce the same result. A dead-letter destination provides the missing final retention point, so the event is still available after the delivery attempt fails.

Why the dead-letter destination wins

Configuring a dead-letter destination on the Event Grid subscription gives rejected events a storage location instead of letting them disappear when delivery fails. The Azure Function can continue returning HTTP 400 for malformed, unexpected, or unauthorized event content, but the event itself is preserved for investigation and possible replay. This is the only option that prevents event loss rather than merely changing delivery behavior.

A retry policy looks related, but it is not a retention mechanism. Event Grid retry settings control how many times delivery is attempted and how long the event remains eligible for delivery. They are useful for transient faults, yet a 400 is a client-side rejection, so retrying the same request does not make the event deliverable. Even if retries are exhausted, the policy alone does not provide a durable copy of the event. The dead-letter destination is what preserves the final failed delivery.

The status-code rule that decides it

The mechanism underneath the choice is Event Grid's treatment of HTTP 400 as a non-retriable client error. When dead-lettering is configured, Event Grid writes the undelivered event to the subscription's dead-letter blob container and records details such as the dead-letter reason and delivery attempts, so an operator can inspect why the Azure Function rejected it. That is the safeguard needed to prevent event loss; without a dead-letter destination, the rejected event has no final resting place.

Optimistic batching changes how events are grouped for delivery and does nothing to keep a rejected event. Asynchronous handshake validation belongs to the subscription validation process and proves that an endpoint can receive Event Grid events; it does not govern what happens after a validated Azure Function returns 400. Neither option creates the durable recovery path that dead-lettering provides.

Official Reference

Exam Strategy

When a question hinges on a specific HTTP status, classify it before choosing between retry and dead-letter. In Event Grid, 400 is a client-side rejection, so configure dead-lettering to retain the event rather than assuming a retry policy will eventually succeed. Scan options for the one that provides durable storage of undelivered events, and reject features like batching or handshake validation that affect delivery mechanics or subscription setup, not event retention.

Practice All AI-200 Questions

Access 69 questions with complete answers and detailed explanations.

View Full AI-200 Practice Test →

← Back to AI-200 Study Guide