Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
99 stars 67 forks source link

Eventhub Trigger Function supporing Azure.Messaging.Eventhubs EventData Type? #491

Open HassanBadir opened 3 years ago

HassanBadir commented 3 years ago

Not sure whether this a bug or feature request, or whether it's supposed to be published here or on the Azure.Messaging.Eventhubs repo, yours to decide.

this is related to this package: Azure.Messaging.EventHubs. and Azure Functions

i am using: Microsoft.NET.Sdk.Functions nuget 3.0.9 Azure.Messaging.EventHubs 5.2.0

The Problem I am facing:

I have an Eventhub Triggered Azure Function, during my work to migrate my function to v3 Function I tried using this nuget Azure.Messaging.EventHubs since it's the latest but I faced this error trying:

when using the EventData Type of Azure.Messaging.EventHubs like in this example: image

I get this error:

Executed 'Function1' (Failed, Id=b6211db9-7044-4602-b0ba-0a8bf1a92cfd, Duration=1305ms)
[2021-01-03T16:24:20.047Z] System.Private.CoreLib: Exception while executing function: Function1. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'events'. Microsoft.Azure.WebJobs.Host: Binding parameters to complex objects (such as 'EventData') uses Json.NET serialization.
1. Bind the parameter type as 'string' instead of 'EventData' to get the raw values and avoid JSON deserialization, or
2. Change the queue payload to be valid json. The JSON parser failed: Unexpected character encountered while parsing value: ?. Path '', line 0, position 0.

it seems that this nuget doesn't support functions yet? or the function doesn't support this nuget? or am I mistaken and some special configuration is needed?

I have to indicate that v3 Function works with Microsoft.Azure.Eventhubs nuget, so isn't it suppose to be supported in Azure.Messaging.Eventhubs

MaDOS commented 2 years ago

Was there ever done any analysis or testing regarding this? I am currently facing the same problem that when using EventData from Azure.Messaging.Eventhubs i can't get the function to work properly (error from OP can still be reproduced). But when using the trigger and models from Microsoft.Azure.WebJobs.Extensions.EventHubs (v4.x) the EventData model still comes from Microsoft.Azure.EventHubs-Namespace. The only NuGet package I was able to find that still includes this class is the before mentioned Microsoft.Azure.EventHubs which is now deprecated.

So I am currently facing the issue that I am working on a library that has to work with the EventData model. But since I can't really get the Trigger to work with Microsoft.Azure.WebJobs.Extensions.EventHubs (v5.x) (using EventData from Azure.Messaging.EventHubs) I have to use the EventData model from Microsoft.Azure.WebJobs.Extensions.EventHubs (v4.x) . But as explained above this Package uses EventData from the Microsoft.Azure.EventHubs-Namespace and I can only get this class from a deprecated NuGet package.

Does anyone know how to resolve this? I really do not want to make this new library dependent on an already deprecated package.