question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] EventGridPublisherClient.SendEventsAsync fails if event handler function receives single EventGridEvent

See original GitHub issue

Given the following Azure Functions v3 precompiled function:

[FunctionName("event-handle")]
public void HandleAsync([EventGridTrigger] EventGridEvent e, ILogger logger)
{
   logger.LogInformation(e.Subject);
}

And an Event Grid Domain (with no custom topic) with a Domain-Scoped Event Subscription (that basically handles every event with no filters whatesoever):

image image

When using the code shown in PublishEventsToTopic to send all events in a batch:

await client.SendEventsAsync(eventsList);

the code fails with:

This resource is configured to receive event in 'EventGridEvent' schema. 
The JSON received does not conform to the expected schema. Token Expected: StartObject, Actual Token Received: EndArray. 

If the code is changed to send each event individually, delivery succeeds.

Expected behavior I would expect the batching on the client to have no impact on how the handling function is authored, and automatically invoke the function multiple times for each sent event.

Environment:

  • Azure.Messaging.EventGrid 4.3.0
  • Hosted Azure Functions v3 runtime
  • Visual Studio 16.10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Jun 29, 2021

Thank you for your feedback. Tagging and routing to the team member best able to assist.

0reactions
JoshLove-msftcommented, Jul 16, 2021

Hi @kzu, We are sorry that you are experiencing trouble here. The stable EventGrid functions bindings still rely on the old Microsoft.Azure.EventGrid library, which is why you are seeing this behavior. There is a beta EventGrid binding that uses the new models defined in Azure.Messaging.EventGrid - https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.0.0-beta.3 If you would like to try it out, things should work more smoothly. Additionally, we will have a stable release of the EventGrid binding in the coming months that you can try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EventGridPublisherClient SendEventAsync doesnt throw ...
it returns 200 and I see the message in Event Grid domain, which topic it will go if the particular topic doesn't exists....
Read more >
Troubleshoot Azure Event Grid issues
During event subscription creation, you may receive an error message that says the validation of the provided endpoint failed.
Read more >
function app can't send message to event grid
SendEventAsync(egEvent) gives me exception error: The given key '1' was not present in the dictionary. I get the key using the azure portal...
Read more >
[BUG] Data property not populated for EventGridEvent object
I want to send an event using event grid, with some data. I have the following snippet of C# code: _logger.LogInformation("Broadcasting event ......
Read more >
Publishing Events to an Event Grid Topic
This sample demonstrates how to publish both Event Grid and CloudEvent 1.0 schema events to the Event Grid service. You can publish events...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found