In Azure Event Grid, when events cannot be delivered to the configured endpoint (in your case, the nonexistent Service Bus Topic test-topic
), Event Grid should attempt to retry delivery according to the configured retry policy. Once the retry attempts are exhausted, Event Grid would typically drop the event, but it doesn't inherently support dead-lettering events to a Storage container.
- If your requirement is specifically to capture failed events and store them in a Storage container, you'll need to implement a custom solution that handles the delivery failure and stores events in the Storage container.
Create a function app and replace the below code to capture incoming events and store them in a Storage container.
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
public static class EventCaptureFunction
{
[FunctionName("EventCaptureFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
// Read the request body
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
// Store the event in a Storage container (replace with your storage logic)
// You would need to use the Azure Storage SDK to accomplish this.
// Example:
// var connectionString = "<YourStorageConnectionString>";
// var containerName = "deadletters";
// var blobName = Guid.NewGuid().ToString() + ".json";
// var blobClient = new BlobClient(connectionString, containerName, blobName);
// await blobClient.UploadAsync(new MemoryStream(Encoding.UTF8.GetBytes(requestBody)));
return new OkObjectResult("Event captured and stored.");
}
}
Set-up the endpoint to trigger to the newly created Azure Function's URL

Trigger events that would normally be sent to your endpoint. Since your configured endpoint is the Azure Function, Event Grid will send events there.
Monitor the Azure Function logs to check that it captures and processes the incoming events.