Azure / Azure/azure-functions-dotnet-worker
Azure Function with Event Hub trigger and `EventData` as argument, fails with serialization error
@soninaren is already working on this.
Since Mar 19, 2025.
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
Description
I am using the sample from https://github.com/Azure/azure-functions-dotnet-worker/blob/main/samples/Extensions/EventHubs/EventHubsFunction.cs, in order to isolate my issue. When running the functions that takes EventData as argument I get a serialization exception from Azure.Core.Amqp. In particular this function from the sample should work:
[Function(nameof(EventDataFunctions))]
public void EventDataFunctions([EventHubTrigger("queue", Connection = "EventHubConnection", IsBatched = false)] EventData @event)
{
_logger.LogInformation("Event Body: {body}", @event.Body);
_logger.LogInformation("Event Content-Type: {contentType}", @event.ContentType);
}
My .csproj, Program.cs, host.json and local.settings.json are all copied from the sample above, and only modified to point to my EventHub in Azure. That is, the sample uses Azure Function version 4, and isolated worker model.
The following exception is thrown
System.Private.CoreLib: Exception while executing function: Functions.EventDataFunctions. Microsoft.Azure.WebJobs.Host:
Exception binding parameter 'event'. Azure.Core.Amqp: Serialization failed due to an unsupported type, System.Byte[].
Steps to reproduce
- Create a project from the sample listed above.
- Configure
local.settings.json - Run
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.