When binding to an evenhub that contains events that where sent without a partitionkey set this package is unable to bind and instead throws an exception.
Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: ProfileEventStorage.storeEvents ---> System.AggregateException : One or more errors occurred. (Exception binding parameter 'data') (Exception binding parameter 'partitionContext') ---> Exception binding parameter 'data' ---> System property 'x-opt-partition-key' is missing in the event.
at Microsoft.Azure.WebJobs.Host.Executors.DelayedException.Throw() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DelayedException.cs : 27
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 511
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 477
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 264
---> (Inner Exception #0) System.InvalidOperationException : Exception binding parameter 'data' ---> System.ArgumentException : System property 'x-opt-partition-key' is missing in the event.
at Microsoft.Azure.EventHubs.EventData.SystemPropertiesCollection.get_PartitionKey()
at Microsoft.Azure.WebJobs.ServiceBus.EventHubTriggerBindingStrategy.AddBindingData(Dictionary2 bindingData,EventData[] events) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.ServiceBus\EventHubs\EventHubTriggerInputBindingStrategy.cs : 111 at Microsoft.Azure.WebJobs.ServiceBus.EventHubTriggerBindingStrategy.GetBindingData(EventHubTriggerInput value) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.ServiceBus\EventHubs\EventHubTriggerInputBindingStrategy.cs : 86 at Microsoft.Azure.WebJobs.Host.ArrayTriggerArgumentBinding2.BindAsync(TTriggerValue value,ValueBindingContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\TriggerArgumentBinding\ArraryTriggerArgumentBinding.cs : 26
at Microsoft.Azure.WebJobs.Host.Triggers.StrategyTriggerBinding2.BindAsync(Object value,ValueBindingContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\StrategyTriggerBinding.cs : 62 at async Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding1.BindCoreAsync[TTriggerValue](ValueBindingContext context,Object value,IDictionary`2 parameters) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\TriggeredFunctionBinding.cs : 57
End of inner exception<---
---> (Inner Exception #1) System.InvalidOperationException : Exception binding parameter 'partitionContext' ---> System.InvalidOperationException : Binding data does not contain expected value 'partitionContext'.
at Microsoft.Azure.WebJobs.Host.Bindings.Data.ClassDataBinding1.BindAsync(BindingContext context) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\Data\ClassDataBinding.cs : 62 at async Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding1.BindCoreAsync[TTriggerValue](ValueBindingContext context,Object value,IDictionary`2 parameters) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Triggers\TriggeredFunctionBinding.cs : 98
End of inner exception<---
When binding to an evenhub that contains events that where sent without a partitionkey set this package is unable to bind and instead throws an exception.
It looks like in the EventHubTriggerBindingStrategy when trying to get the partition key is where this exception happens.
Repro steps
Provide the steps required to reproduce the problem
Expected behavior
Not throw an exception and bind the event data.
Actual behavior
Throws an exception
Known workarounds
Use Microsoft.Azure.EventHubs.Processor directly and bypass the webjobs package
Related information
function I used:
let storeEvents ([<EventHubTrigger("someeventhub" ConsumerGroup="testevents")>] events:EventData [],partitionContext:PartitionContext) = async { printfn "%A" events.Length } |> Async.StartAsTask :> Task
Stack trace snippet: