Azure / Azure/azure-functions-dotnet-worker

.Net 8 isolated function app with Eventhub trigger - Serialization issue when message is published via nodejs with extra properties.

Open
#2,659 0 comments 0 reactions 0 assignees View on GitHub
extensions: event-hubs needs-investigation potential-bug
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

I am upgrading .Net 6 Function in-process function app to .Net 8 Isolated function app. I am using all latest libraries which are recently upgraded.

I am using nodejs code to publish my events and below is the code.

```

const connectionString = "{conn_str}"
const eventHubName = "{hubName}";
const producer = new EventHubProducerClient(connectionString, eventHubName);

let evtData = {body: {"id":"c99bc0ea-6732-46ff-b1c0-6183e788e8a9","topic":"Test","subject":"playwright-test","data":{},"eventType":"Test.Logged","eventTime":"2024-08-13T18:26:28.510Z","metadataVersion":"1","dataVersion":"1"}
, properties:[{clientId:"133343fa-97ba-41c5-a9ba-228a560860a3"}]
};
const batch = await producer.createBatch();
batch.tryAdd(evtData );
await producer.sendBatch(batch);
```
I am getting below error on my .Net8 function app

```
System.Runtime.Serialization.SerializationException:
at Azure.Core.Amqp.Shared.AmqpAnnotatedMessageConverter.TryCreateNetPropertyFromAmqpProperty (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Azure.Core.Amqp.Shared.AmqpAnnotatedMessageConverter.FromAmqpMessage (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Azure.Messaging.EventHubs.Amqp.AmqpMessageConverter.BuildEventFromAmqpMessage (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Azure.Messaging.EventHubs.Amqp.AmqpMessageConverter.CreateEventFromMessage (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Azure.Messaging.EventHubs.Amqp.AmqpConsumer+d__42.MoveNext (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.EventHubs.Amqp.AmqpConsumer+d__42.MoveNext (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.EventHubs.Primitives.EventProcessor`1+<>c__DisplayClass75_0+<g__performProcessing|1>d.MoveNext (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.EventHubs.Primitives.EventProcessor`1+<>c__DisplayClass75_0+<g__performProcessing|1>d.MoveNext (Azure.Messaging.EventHubs, Version=5.11.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
```

It is not even reaching any code written inside trigger.

This is blocker to us for our .Net 8 upgrade as many of our clients are using NodeJs to publish their messages to eventhub.

Versions
=======

**Publisher NodeJs**
Node Version: 20
@azure/event-hubs: "5.12.0"

**Function App**
.Net 8 Isolated
Microsoft.Azure.Functions.Worker.Extensions.EventHubs: 6.3.5

### Steps to reproduce

publish Events(eventgrid event type) to Eventhub using nodejs with extra properties.

```

const connectionString = "{conn_str}"
const eventHubName = "{hubName}";
const producer = new EventHubProducerClient(connectionString, eventHubName);

let evtData = {body: {"id":"c99bc0ea-6732-46ff-b1c0-6183e788e8a9","topic":"Test","subject":"playwright-test","data":{},"eventType":"Test.Logged","eventTime":"2024-08-13T18:26:28.510Z","metadataVersion":"1","dataVersion":"1"}
, properties:[{clientId:"133343fa-97ba-41c5-a9ba-228a560860a3"}] // This property is mandatory for us in order to process message.
};
const batch = await producer.createBatch();
batch.tryAdd(evtData );
await producer.sendBatch(batch);
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Node.js EventHubProducerClient reproduction and the .NET 8 isolated Event Hub trigger. Trace the Azure.Messaging.EventHubs AmqpMessageConverter.TryCreateNetPropertyFromAmqpProperty failure shown in the stack trace. Done means an event containing the extra properties reaches the trigger without a SerializationException.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.