Azure Event Hub Python SDK - does EventDataBatch go to a single partition even without partition_key or partition_id?

Wessel Vonk 45 Reputation points
2025-04-16T15:12:01.4366667+00:00

Hi, I'm working with Azure Event Hubs using the Python SDK. I’ve been reviewing the documentation here: https://learn.microsoft.com/en-us/python/api/azure-eventhub/azure.eventhub.eventdatabatch?view=azure-python.

I'm creating an EventDataBatch using EventHubProducerClient.create_batch() without specifying a partition_key or partition_id. When I send this batch using send_batch(), it seems that all events in the batch consistently end up on the same partition (out of three total).

Is this behavior guaranteed? Does EventDataBatch always send all events to a single partition, even if no partition_key or partition_id is specified?

Thanks!

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
711 questions
{count} votes

Accepted answer
  1. J N S S Kasyap 1,715 Reputation points Microsoft External Staff
    2025-04-16T17:25:40.62+00:00

    @Wessel Vonk
    The behavior where all events in a single EventDataBatch go to the same partition is guaranteed when using send_batch(). However, without a partition_key or partition_id, the specific partition chosen is not guaranteed and depends on the client library's internal load-balancing logic. If you need control over partitioning or distribution, explicitly set a partition_key or partition_id, or send multiple batches.
    Please refer the below Microsoft documentation for more information

    https://learn.microsoft.com/en-us/python/api/azure-eventhub/azure.eventhub.eventhubproducerclient?view=azure-python

    https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-features#event-publishing
     I hope this information helps. Please do let us know if you have any further queries.

    Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.

    Thank you.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.