[Visual Studio] Event Hub not working on dotnet core
I am unsure if Event Hub is already working with dotnet core. If it is not, disconsider my issue.
I have created a new Azure Function solution and added 2 functions:
public static class FuncTimer
{
[FunctionName("FuncTimer")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, [EventHub("test-eh", Connection = "Test_EventHub")] ICollector<string> outputEventHubMessages, TraceWriter log)
{
outputEventHubMessages.Add("1 test");
outputEventHubMessages.Add("2 test");
outputEventHubMessages.Add("3 test");
}
}
public static class FuncEvent
{
[FunctionName("FuncEvent")]
public static void Run([EventHubTrigger("test-eh", Connection = "Test_EventHub")] string[] eventHubMessages, TraceWriter log)
{
foreach (var message in eventHubMessages)
{
log.Info($"C# Event Hub trigger function processed a message: {message}");
}
}
}
I also added the the EventHub Extension NuGet package:
Install-Package Microsoft.Azure.WebJobs.Extensions.EventHubs -Version 3.0.0-beta3
The FuncTimer works like a charm. I am able to add events through the ICollector. The FuncEvent, on the other hand, doesn't. This is the error I get:
[08/12/17 17:43:08] FuncEvent: Unabled to configure binding 'eventHubMessages' of type 'eventHubTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call.
We should be supporting it, as shown in this documentation.
@ConnorMcMahon It is supported, but apparently it has a bug when working with an array. Single messages work like a charm
Seems to me the same as https://github.com/Azure/Azure-Functions/issues/652 As I explain there, in the function.json file the property "path" should be "eventhubname". Manual change can get you going.
This should have been fixed and is working now. Let me know if you have any other ?s