Azure / Azure/azure-functions-dotnet-worker

EventGridEvent 'data property' empty when ObjectSerializer set to NewtonsoftJsonObjectSerializer

Open
#1,507 0 comments 0 reactions 0 assignees View on GitHub
area: binding extensions: event-grid feature: sdk-bindings needs-investigation
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

I am using NewtonsoftJsonObjectSerializer in the workerdefault settings. I set this like so:
```
.ConfigureFunctionsWorkerDefaults((hostContext, applicationBuilder) =>
{
...
}, o =>
{
o.Serializer = new NewtonsoftJsonObjectSerializer(JsonUtils.JsonSerializerSettings);
})
```
Now when I create a EventGridEvent object and sent is trough an output binding the data property is filled but when I receive it in my logic app the data property is empty:
![image](https://user-images.githubusercontent.com/18898792/236043060-9fec4f10-f627-4145-970b-aa661ddc0677.png)

This is how I create the messages:

```
[EventGridOutput(TopicEndpointUri = "IfsEmployeeEventGridTopicUriSetting", TopicKeySetting = "IfsEmployeeEventGridTopicKeySetting")]
public async Task> Run(
.....

var employeeChanges = await _gech.Execute();
var eventMessages = employeeChanges
.Select(m => new EventGridEvent($"{m.Subject}", "Employee", "1.0", m)
{
Id = $"{m.NewEmployeeEntity.PersonId}_Employee",
EventTime = m.NewEmployeeEntity.TimestampOrDefault.UtcDateTime
}).ToList();

return eventMessages;
....)
```
When I look at the Data propery in debugmode I see the data property filled, but I is not using my JsonSerializerSettings, because it is written as PascalCase and not camelCase.
![image](https://user-images.githubusercontent.com/18898792/236042597-b029e1ce-dd53-4a81-a574-5e4d63132e63.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how ConfigureFunctionsWorkerDefaults applies NewtonsoftJsonObjectSerializer to the EventGridOutput binding, using the EventGridEvent construction shown in the issue. Compare the serialized payload sent through the output binding with the populated Data value seen in the debugger; done means the received Logic App event contains the expected data using the configured serializer settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.