This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Event Hubs provides message streaming through a partitioned consumer pattern in which each consumer only reads a specific subset, or partition, of the message stream. This pattern enables horizontal scale for event processing and provides other stream-focused features that are unavailable in queues and topics. A partition is an ordered sequence of events that is held in an event hub. As newer events arrive, they're added to the end of this sequence. For more information about partitions in general, seePartitions
You can specify the number of partitions at the time of creating an event hub. In some scenarios, you may need to add partitions after the event hub has been created. This article describes how to dynamically add partitions to an existing event hub.
Important
Dynamic additions of partitions is available only inpremium anddedicated tiers of Event Hubs.
Note
For Apache Kafka clients, anevent hub maps to aKafka topic. For more mappings between Azure Event Hubs and Apache Kafka, seeKafka and Event Hubs conceptual mapping
This section shows you how to update partition count of an event hub in different ways (PowerShell, CLI, and so on.).
Use theSet-AzEventHub PowerShell command to update partitions in an event hub.
Set-AzEventHub -ResourceGroupName MyResourceGroupName -Namespace MyNamespaceName -Name MyEventHubName -partitionCount 12Use theaz eventhubs eventhub update CLI command to update partitions in an event hub.
az eventhubs eventhub update --resource-group MyResourceGroupName --namespace-name MyNamespaceName --name MyEventHubName --partition-count 12Update value of thepartitionCount property in the Resource Manager template and redeploy the template to update the resource.
{ "apiVersion": "2017-04-01", "type": "Microsoft.EventHub/namespaces/eventhubs", "name": "[concat(parameters('namespaceName'), '/', parameters('eventHubName'))]", "location": "[parameters('location')]", "dependsOn": [ "[resourceId('Microsoft.EventHub/namespaces', parameters('namespaceName'))]" ], "properties": { "messageRetentionInDays": 7, "partitionCount": 12 } }Use theAlterTopics API (for example, viakafka-topics CLI tool) to increase the partition count. For details, seeModifying Kafka topics.
Let's look at how Event Hubs clients behave when the partition count is updated on an event hub.
When you add a partition to an existing even hub, the event hub client receives aMessagingException from the service informing the clients that entity metadata (entity is your event hub and metadata is the partition information) has been altered. The clients will automatically reopen the AMQP links, which would then pick up the changed metadata information. The clients then operate normally.
Event Hubs provides three sender options:
Event Hubs provides direct receivers and an easy consumer library called theEvent Processor.
Direct receivers – The direct receivers listen to specific partitions. Their runtime behavior isn't affected when partitions are scaled out for an event hub. The application that uses direct receivers needs to take care of picking up the new partitions and assigning the receivers accordingly.
Event processor host – This client doesn't automatically refresh the entity metadata. So, it wouldn't pick up on partition count increase. Recreating an event processor instance will cause an entity metadata fetch, which in turn will create new blobs for the newly added partitions. Pre-existing blobs won't be affected. Restarting all event processor instances is recommended to ensure that all instances are aware of the newly added partitions, and load-balancing is handled correctly among consumers.
If you're using the old version of .NET SDK (WindowsAzure.ServiceBus), the event processor host removes an existing checkpoint upon restart if partition count in the checkpoint doesn't match the partition count fetched from the service. This behavior may have an impact on your application.
On 30 September 2026, we'll retire the Azure Service Bus SDK libraries WindowsAzure.ServiceBus, Microsoft.Azure.ServiceBus, and com.microsoft.azure.servicebus, which don't conform to Azure SDK guidelines. We'll also end support of the SBMP protocol, so you'll no longer be able to use this protocol after 30 September 2026. Migrate to the latest Azure SDK libraries, which offer critical security updates and improved capabilities, before that date.
Although the older libraries can still be used beyond 30 September 2026, they'll no longer receive official support and updates from Microsoft. For more information, see thesupport retirement announcement.
This section describes how Apache Kafka clients that use the Kafka endpoint of Azure Event Hubs behave when the partition count is updated for an event hub.
Kafka clients that use Event Hubs with the Apache Kafka protocol behave differently from event hub clients that use AMQP protocol. Kafka clients update their metadata once everymetadata.max.age.ms milliseconds. You specify this value in the client configurations. Thelibrdkafka libraries also use the same configuration. Metadata updates inform the clients of service changes including the partition count increases. For a list of configurations, seeApache Kafka configurations for Event Hubs.
Producers always dictate that send requests contain the partition destination for each set of produced records. So, all produce partitioning is done on client-side with producer’s view of broker's metadata. Once the new partitions are added to the producer’s metadata view, they'll be available for producer requests.
When a consumer group member performs a metadata refresh and picks up the newly created partitions, that member initiates a group rebalance. Consumer metadata then will be refreshed for all group members, and the new partitions will be assigned by the allotted rebalance leader.
If you use partition key with your producer applications and depend on key hashing to ensure ordering in a partition, dynamically adding partitions isn't recommended.
Important
While the existing data preserves ordering, partition hashing will be broken for messages hashed after the partition count changes due to addition of partitions.
Adding partition to an existing topic or event hub instance is recommended in the following cases:
For more information about partitions, seePartitions.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?