0

I could find a document or example of eventhub output binding supporting a partitionKey. The below link says it is an option for trigger metadata however there is no java example.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-event-hubs#trigger---event-metadata

Did I miss anything in this document or its still not supported?

Thanks in Advance

T D
  • 1,080
  • 2
  • 13
  • 20

1 Answers1

0

If you want an example about how to use trigger metadata, you could refer to the below code or you could go to the github check the code. The below is my test code.

public class Eventhubtest {
    /**
     * This function will be invoked when an event is received from Event Hub.
     */
    @FunctionName("Eventhubtest")
    public void run(
        @EventHubTrigger(name = "message", eventHubName = "myevent", connection = "EventHubConnection", cardinality = Cardinality.MANY)String message,
        @BindingName("SystemPropertiesArray") SystemProperty[] systemPropertiesArray,
        final ExecutionContext context) {
        context.getLogger().info("Java Event Hub trigger function executed."+message);
        context.getLogger().info("SystemProperties for message[0]: EnqueuedTimeUtc=" + systemPropertiesArray[0].EnqueuedTimeUtc +" Offset=" +systemPropertiesArray[0].Offset+" PartitionKey="+ systemPropertiesArray[0].PartitionKey);



    }
    public static class SystemProperty {
        public String SequenceNumber;
        public String Offset;
        public String PartitionKey;
        public String EnqueuedTimeUtc;
    }
}

And here is the result. You could find the PartitionKey is available in the pic.

enter image description here

George Chen
  • 13,703
  • 2
  • 11
  • 26