Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
737 stars 358 forks source link

Trigger Binding Data - EventData properties not binding #1325

Open Blackbaud-PeteLukich opened 7 years ago

Blackbaud-PeteLukich commented 7 years ago

Binding an EventHubTrigger method's parameters to EventData properties throws an error.

Repro steps

I am following the first example for EventHubTrigger, here: https://github.com/Azure/azure-webjobs-sdk/wiki/Trigger-Binding-Data

  1. Copy/paste this example into my EventHubTrigger method, so the method signature looks like: public static void ProcessMessage( [EventHubTrigger(Constants.EventHubName, ConsumerGroup = Constants.ConsumerGroupName)] MyMessage message, string partitionKey, DateTime enqueuedTimeUtc, IDictionary<string, object> properties, IDictionary<string, object> systemProperties) { ...
  2. Start my WebJob
  3. This error is thrown: Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: 'Error indexing method 'Functions.ProcessMessage'' InnerException: InvalidOperationException: Cannot bind parameter 'partitionKey' to type String. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

Expected behavior

WebJob should start successfully, and receive my un-read messages (as it did before I pasted in these additional binding properties. When the only parameter that I had was MyMessage message, everything was working fine.

Actual behavior

When RunAndBlock() is called, the error above is thrown as the WebJob tries to bind my EventHubTrigger method and its parameters (which now contain all the ones listed above that are properties of EventData, in addition to the MyMessage parameter).

Known workarounds

Do not attempt to bind to any EventData properties such as enqueuedTimeUtc (which I'm most interested in accessing).

Related information

christopheranderson commented 6 years ago

You need to use the class "EventData" if you want that, or you need to add it your your MyMessage definition.