Cloud
Azure Event Grid: diagnose webhook validation before changing security
A runbook for isolating Event Grid webhook validation failures, fixing the handshake and proving delivery without blindly opening the endpoint.
A team deploys a new webhook to receive storage events. Event Grid fails to create the event subscription during endpoint validation, although the API responds to a local test. Disabling the WAF or relaxing authentication may make a test pass without proving that the right endpoint was validated or that business events will be processed.
This runbook uses a fictional Azure Event Grid Basic topic with Event Grid schema and an HTTP webhook behind a gateway. It separates endpoint ownership validation from business event delivery. Namespace topics and CloudEvents use different mechanisms: check their documentation before applying this handshake.
Freeze the change and collect evidence
Keep the existing subscription and destination in place if they still serve production. Pause repeated creation attempts and record the UTC window, operation correlation ID, topic, resource group, provisioning state, event schema, destination URL without secrets, deployed version and gateway changes. Restrict access to evidence: URLs, headers and payloads can contain sensitive information.
Map the actual path: Event Grid, public DNS, TLS certificate, gateway or WAF, route and application. A request from an operator’s laptop or internal network may not take the same path. Compare gateway and application logs over the same UTC window. An absent application log alone does not prove a network block; check routing, filters and log collection too.
| Evidence | Next distinction |
|---|---|
| No request at the gateway | Public resolution, TLS, path reachability or gateway observability |
| Request rejected at the gateway | WAF rule, access control or routing before the application |
| Request received but response incorrect | HTTP status, JSON body, latency or event-type handling |
| Validation succeeds but business event is missing | Filter, publication, delivery, processing or deduplication: a separate incident |
Verify the validation contract
For the synchronous Event Grid schema handshake, Event Grid sends an array containing a Microsoft.EventGrid.SubscriptionValidationEvent. The handler must respond with HTTP 200 and a JSON object whose validationResponse exactly echoes data.validationCode, within 30 seconds. A 202 Accepted does not complete this handshake, even though it may be valid for other delivery stages. The code is validation data, not a business event: it must not trigger processing or be retained in logs.
{
"validationResponse": "<received validationCode>"
}
Check the event type before reading data.validationCode, the input array, the actual response body returned through the gateway, status and latency. A login page or proxy-replaced body can return HTTP 200 without meeting the contract. An Azure Functions Event Grid trigger can handle validation itself; a generic HTTP trigger needs an appropriate handler. The Microsoft endpoint validation documentation also describes asynchronous validation: follow a validation URL only after verifying its origin and using the approved procedure.
A controlled preproduction test can send a synthetic validation event with a fictitious code to the test URL, then check the status, JSON and elapsed time. This exercises the handler and that client’s path, not actual Event Grid reachability. Do not put secret-bearing URLs or real payloads in a ticket.
Change one layer at a time
If the gateway blocks the request, qualify the rule and its scope with the security team before making an exception. Prefer a documented correction limited to the required path and behavior, with an expiry under local policy; do not disable the WAF globally. Check the certificate, host name and effective route before changing the network. If the handler responds incorrectly, fix its contract in a traceable release without bypassing business-traffic access controls.
Prepare an isolated canary subscription and endpoint with an agreed filter and destination, without irreversible business effects. Record the previous release, gateway configuration, owner, stop criteria and restoration method. Ownership validation is not a substitute for authentication, authorization or idempotent event processing.
Prove delivery and decide
Create the canary subscription and establish that Event Grid actually completed validation using the relevant logs. Then publish an identifiable test event within the authorized scope and correlate publication, delivery, webhook response and expected business effect. Check a rejected or out-of-filter case as well, without exposing sensitive data. Observe metrics and the configured dead-letter destination, including its permissions and reachability.
Do not assume every failure will be retried. For a Basic webhook, certain statuses, including 400, 401, 403 and 413, are not retried; events can be lost without a usable dead-letter destination. Retries can also result in duplicates. Review the applicable delivery and retry policy and prove idempotency before replay. Successful webhook validation does not establish completeness of events missed during the incident.
Expand only after the actual handshake, security controls and canary processing are demonstrated. Otherwise stop promotion, restore the previous release and configuration using the local procedure, and verify that the old path still works. Restoration cannot recover lost events: reconcile source and destination, then agree a bounded, deduplicated recovery with the service owner.