Share via

Iot Hub Partition Id algorithm

Emilio Palma 0 Reputation points
2026-02-06T14:09:57.4333333+00:00

Hi,

Considering that an implementation of the Iot Hub partitioning algorithm is public (MIT licensed) (https://github.com/Azure/azure-iot-sdk-csharp/blob/main/iothub/service/src/Common/PerfectHash.cs),

does the following recommendation still apply without qualification?

We recommend listing the blobs or files and then iterating over them, to ensure that all blobs or files are read without making any assumptions of partition. The partition range could potentially change during a Microsoft-initiated failover or IoT Hub manual failover.
(https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-endpoints)

Best regards,

Emilio Palma

Azure IoT Hub
Azure IoT Hub

An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Zohaib Rizwan 20 Reputation points
    2026-02-06T14:13:39.55+00:00

    Hi Emilio,

    Yes, the recommendation still applies without qualification, even though an implementation of the IoT Hub partitioning algorithm is publicly available.

    While the PerfectHash implementation in the Azure IoT SDK shows how partitions are currently calculated, it should be considered an implementation detail, not a contractual guarantee. Microsoft does not guarantee that the partitioning algorithm, partition count, or partition-to-resource mapping will remain unchanged over time.

    In particular:

    The number of partitions and their ranges may change during Microsoft-initiated failovers or manual IoT Hub failovers.

    Relying on a specific partitioning behavior can lead to missed data or partial reads if the partition layout changes.

    The public SDK implementation reflects the current behavior but is not part of the documented service contract.

    For these reasons, the documented guidance to list blobs/files and iterate over them remains the safest and recommended approach. This ensures that all data is read reliably without making assumptions about partition stability.

    In short, even with access to the algorithm, applications should treat partitions as opaque and mutable and follow the official documentation to ensure correctness and resilience.

    Hope this helps.


  2. Q&A Assist
    2026-02-06T14:10:37.6066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The recommendation to list the blobs or files and iterate over them to ensure all blobs or files are read still applies. This is important because the partition range can change during a Microsoft-initiated failover or an IoT Hub manual failover. Therefore, relying solely on the partitioning algorithm without this precaution could lead to incomplete data retrieval or assumptions that may not hold true during such events.

    It is always best practice to ensure that you are reading all available data without making assumptions about the state of the partitions, especially in a distributed system like Azure IoT Hub.


    References:

    0 comments No comments

Your answer

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