CodexBloom - Programming Q&A Platform

Azure Function with Event Grid Trigger: Missing Event Data in Function JSON

👀 Views: 1282 đŸ’Ŧ Answers: 1 📅 Created: 2025-08-24
azure-functions event-grid csharp C#

I'm trying to figure out I'm attempting to set up I'm upgrading from an older version and I'm maintaining legacy code that I'm working on an Azure Function that is triggered by an Event Grid event..... I've set up everything according to the documentation, but I'm working with a strange scenario where the function seems to be triggered correctly, yet I'm only seeing a partial payload in the function's execution context. My function is defined like this: ```csharp public static class EventGridFunction { [FunctionName("EventGridFunction")] public static async Task Run([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log) { log.LogInformation($"Event received: {eventGridEvent.Data}"); // Additional processing... } } ``` The event is successfully published to Event Grid, and I can see it in the Azure portal's monitoring tab. However, when the function runs, the `eventGridEvent.Data` is sometimes returning null or an empty object. I've set the correct schema for the event in Event Grid, which looks like this: ```json { "id": "1234", "eventType": "recordInserted", "subject": "mySubject", "eventTime": "2023-10-01T12:00:00Z", "data": { "property1": "value1", "property2": "value2" }, "dataVersion": "1.0" } ``` I've checked the function's bindings and they seem correct, yet this scenario occurs intermittently, leading me to suspect it might be related to the event schema or serialization question. I have tried to log the entire `eventGridEvent` object and it shows that the `Data` property is indeed null in some executions. I've also examined the 'Custom Event' settings in Event Grid to ensure that the schema is aligned with what the function expects. I am using Azure Functions v3 and the latest version of the Azure Functions SDK. Any insights on why this might be occurring or how I can ensure consistent event data is passed to the function? For context: I'm using C# on CentOS. Cheers for any assistance! Any feedback is welcome! Could someone point me to the right documentation? What's the best practice here?