@Karl Gardner - Thanks for the question and using MS Q&A platform.
In the output configuration for Azure Stream Analytics, the Partition Key column is optional for Event Hub output. If you specify a Partition Key column, Stream Analytics will use the value in that column to determine the partition to which the event should be written in Event Hub. If you don't specify a Partition Key column, Stream Analytics will use the default round-robin partitioning scheme to determine the partition to which the event should be written.
The following table has the parameters needed to configure data streams from event hubs as an output.
When a partition key is specified to map incoming event data to specific partitions, the PartitionId field will stay the same in Event Hub and a Partition Key field is added to the metadata. The Partition Key is a sender-supplied value passed into an event hub and is processed through a static hashing function, which creates the partition assignment.
Regarding your follow-up question, to add a Partition Key in an Event Hub input to Stream Analytics, you can use the PARTITION BY clause in the query. Here is an example:
SELECT *
INTO output
FROM input
PARTITION BY PartitionKey
In this example, "PartitionKey" is the name of the field in the input data that contains the partition key. You can replace "PartitionKey" with the actual name of the field in your input data that contains the partition key.
For more details, refer to Mapping of events to partitions and Use repartitioning to optimize processing with Azure Stream Analytics
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.