Question

Difficulty: MediumImplement Azure Event Grid Solutions

You are developing a custom ASP.NET Core Web API that will consume events from an Azure Event Grid system topic. When you attempt to create the Event Grid subscription with the Web API endpoint as the Webhook destination, the subscription creation fails. You determine that the Web API endpoint is not correctly responding to the subscription validation request sent by Event Grid.

Which response must the Web API endpoint return to Event Grid to successfully complete the synchronous subscription validation handshake?

  1. An HTTP 200 OK response containing a JSON object in the body with a property named validationResponse set to the value of validationCode found in the request event data.Answer
  2. B
    An HTTP 200 OK response containing a JSON object in the body with a property named validationCode set to the value of validationResponse found in the request event data.
  3. C
    An HTTP 202 Accepted response containing a SAS token in the authorization header that grants the event subscription access to the Web API endpoint.
  4. D
    An HTTP 200 OK response containing a JSON object in the body with a client secret retrieved from Azure Key Vault to authenticate the subscription's system-assigned managed identity.

Answer

An HTTP 200 OK response containing a JSON object in the body with a property named validationResponse set to the value of validationCode found in the request event data.
For synchronous endpoint validation, Azure Event Grid sends a subscription validation event to the configured Webhook endpoint. The endpoint must respond with an HTTP status code 200 OK and a JSON body containing a property named validationResponse set to the value of validationCode that was sent in the request payload.

Step-by-Step Solution

1
Extract the request body JSON payload sent by Azure Event Grid during subscription creation.
You obtain an array containing a validation event of type Microsoft.EventGrid.SubscriptionValidationEvent.
Event Grid sends a validation event containing a validationCode in the data object to verify the endpoint ownership.
2
Parse the validationCode from the event data object.
You retrieve the unique validation code string sent by Event Grid.
This code must be returned back to Event Grid to prove control of the webhook endpoint.
3
Construct a JSON response with a single property named validationResponse, assigning it the extracted validationCode value, and return it with a 200 OK HTTP status.
The validation process succeeds, and the Event Grid subscription is successfully created.
Event Grid expects this specific JSON structure and HTTP status code to verify the handshake synchronously.

Key Concept

Azure Event Grid Webhook endpoint validation handshake requires echoing the validationCode using the validationResponse key in an HTTP 200 OK response.
Estimated Time:1m 30s
Rate this question