Azure / Azure/azure-functions-dotnet-worker

Azure Function with Event Hub trigger and `EventData` as argument, fails with serialization error

Open
#2,481 2 comments 0 reactions 1 assignee View on GitHub

@soninaren is already working on this.

Since Mar 19, 2025.

Needs: Triage (Functions) potential-bug
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
  1. Create a project from the sample listed above.
  2. Configure local.settings.json
  3. Run

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.