I want to copy events including their header data unchanged to another Event Hub.
What I tried so far:
byte[]
, the function fails on the output side with a message that it cannot serialize them. The messages are written to the source Event Hub with Kafka, which means all headers will be of type byte[]
.Are there simpler ways to do this?
There is a set of Event replication tasks for Azure Functions which are intended to do the translation work and make forwarding events to a second Event Hub easy.
That said, I do not know if it supports maintaining the partition key when doing so - you'd want to test that out to be sure. If not, you would need to manipulate the underlying AMQP Message to attach it.
To do so, you'd call the GetRawAmqpMessage on your destination EventData
instance. On the AmqpAnnotatedMessage
that gets returned, you'd inject the partition key into the Message Annotations
section manually by adding an item with the key x-opt-partition-key
and value of the partition key that you'd like it to reflect.
If the replication tasks don't meet your needs for some reason, the best approach would likely be manually publishing events using the method that is discussed in this answer.