Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 441 forks source link

EventHubTrigger fails on message binding on runtime 2 #2915

Open NucleoTech opened 6 years ago

NucleoTech commented 6 years ago

I have an EventHubTrigger function (.NET Standard 2.0) developed in Visual Studio that works correctly when running from VS, but fails when invoked on Azure platform [runtime 2.0.11776.0 (beta)]. The failure seems to be a parameter binding issue.

The IOT hub routes messages to the built-in events endpoint. I created a 'hotpath' consumer group.

Investigative information

Please provide the following:

Repro steps

In VS on local PC:

  1. Start debug session in VS 2.HTTP POST test message to IOT hub using the URL: https://<>.azure-devices.net/devices/CSS-TEST/messages/events?api-version=2016-02-03
  2. Azure hosting environment displays the log message that message was processed

On Azure:

  1. HTTP POST test message to IOT hub using the URL: https://<>.azure-devices.net/devices/CSS-TEST/messages/events?api-version=2016-02-03
  2. Function logs report error executing the function

Expected behavior

Function should successfully execute on Azure as it does on local PC.

Actual behavior

Function execution on Azure fails with error: Failure: Exception binding parameter 'myEventHubMessage' Parameter: myEventHubMessage Value: Object reference not set to an instance of an object.

Known workarounds

None

Related information

Provide any related information

Source ```csharp public static class HandleDeviceEvent { [FunctionName("HandleDeviceEvent")] public static void Run( [EventHubTrigger("platformeventhub",Connection = "PlatformEventHub_events", ConsumerGroup = "hotpath")]string myEventHubMessage, [Table("PlatformSummary")] CloudTable platformSummaries, TraceWriter log) { log.Info($"Some message {DateTime.UtcNow}:{myEventHubMessage}"); } } ```
paulbatum commented 6 years ago

Did you set an appsetting in the portal for your function app with name "PlatformEventHub_events" containing your connection string? Because it looks like you might have that in your local settings file but the local file is not used when you're running in Azure.

MBhatt01 commented 6 years ago

@NucleoTech Have you got any solution for this issue? I am facing similar issue with EventHubTrigger (2.0). It works correctly on local machine, but after deploying to Azure it says "error: Can't figure out which ctor to call."