IoT Hub Routing Messages to Only One Partition of Event Hub - azure

I have a data pipeline set up in Azure where I send messages to an IoTHub which then routes those messages to an EventHub. When I read from the EventHub using the standard EventProcessorHost method, I find that only one of the partitions is being read from. I assume that only one partition is actually having messages routed to it. I have not specified a partition key anywhere and expect that the messages would be routed to all of the partitions of the event hub using round robin (as per the documentation at https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-programming-guide).
How can I configure my setup to route messages to all partitions of the event hub?

Like I said in the comment:
Is it possible you are only receiving data from one device? IoT Hub does automatic partitioning based on the deviceId, so the partition affinity might be the cause.

Related

Azure IoT Hub routing to Event Hub

I created a Event Hub with 32 partitions and doing the message injection over the IoT Hub message routing.
If i connect with Stream Analytics to my Event Hub and look at the input i get this message: "While sampling data, no data was received from '31' partitions"
I thought that if i have multiple partitions all the messages will be distributed over all the partitions and not land in one.
If this is intended, then whats the use to have multiple partitions when using Stream Analytics with Event Hub as input?
IoT Hub will use the device ID as the partition key I think.
So if you receive data only from one device, they will all go to one partition of the Event Hub.
You'll get more usage of the partitions by having more devices sending data to IoT Hub.

AZURE Event Hub processing multiple protocols to same Topic

Upon reading on AZURE Event Hub,
I note that we can send data via
http(s)
AMQP
KAFKA
As I am not an integration (messaging) expert, the following then:
Can I use both AMQP and http(s) to write to the same Event Hub Topic
and subsequently can a single AZURE Function read from that same single Event Hub Topic regardless of how written to?
For KAFKA, this will need to be always a separate Event Hub (Topic) is my understanding.
The AZURE EVENT HUB KAFKA look-like API means that, if you, say, all send a JSON format using all 3 protocols, they can be mapped to the same Event Hub (= Topic), and one can read the Event Hub in KAFKA mode, say.
This is a good read https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-exchange-events-different-protocols but I checked with a more experienced person to confirm.

purpose of Azure iot hub device-to-cloud partitions

When creating a new Azure IOT Hub you are asked how many device-to-cloud partitions you need. You can select between 2-32 partitions for standard tiers.
I understand that the SKU and number of units determine the maximum daily quota of messages that you can send to IOT Hub. And that it is recommended to shard your devices into multiple IOT hubs to smooth traffic bursts. However, device-to-cloud partitions need clarification.
1>> What is the purpose of those device-to-cloud partitions under a single IOT hub?
2>> How are we supposed to take advantage of those IOT Hub device-to-cloud partitions? 
Thanks.
1>> What is the purpose of those device-to-cloud partitions under a
single IOT hub?
Partition property is setting for Event Hub-compatible messaging endpoint(messages/events) built in Azure IoT Hub. From here we can see "partitions" is a concept belongs to Event Hub.
Event Hubs is designed to allow a single partition reader per consumer group. A single partition within a consumer group cannot have more than 5 concurrent readers connected at any time. More partitions enables you to have more concurrent readers processing your data, improving your aggregate throughput.
Ref: Built-in endpoint: messages/events and How many partitions do I need?
2>> How are we supposed to take advantage of those IOT Hub
device-to-cloud partitions?
Event Hubs has two primary models for event consumption: direct receivers and higher-level abstractions, such as EventProcessorHost. Direct receivers are responsible for their own coordination of access to partitions within a consumer group.
Ref:Event consumers.
More information about the partitioning model of Azure Event Hubs are here.

Sending message to Azure IoT hub partition

Does anyone know if there is a library that allows you to send a message to a specific partition on an IoT hub with Azure.
I was previously able to achieve this with azuresblite library, unfortunatelly which I Cannot use.
https://github.com/ppatierno/azuresblite
There is no way to send a message to a specific partition. Period.
Partitions are used internally to allow scaling of the IoT (Event Hub) and allow for scaling out the consumer app (the one that reads the events out of the Hub).
While you can specify a Partition Key when using Event Hub, this does identify a Partition ID. And using IoT Hub, the option to specify Partition Key is anyway hidden and you cannot influence it. Specifying a Partition Key for a message in Event Hub will just make sure that all messages with the same partition key will fall into the same partition. But you cannot tell which partition (0,1,2..n). I have seen projects which try to literary abuse the Partitions and use them as "tenants". Very wrong way of completely abusing scalability of Event Hubs.
Please do not abuse the partitioning of Event Hub (which is anyway the back-end system for an IoT Hub). Do not force Partition Keys. Thus you are unbalancing the Event Hub and may go into a wrong direction. Instead please clearly define a technical issue you are trying to solve and we may be able to help you.
Azure IoT Hub ensures proper ordering of messages while messages are read from IoT Hub. PF the link for more details -
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-d2c#ordering-guarantees-with-at-least-once-delivery

What is Partition Id,Offset,Host Name in Azure Event Hub Receiver?

I am working in azure event hub. I have some doubts.
What is Partition Id in Azure event hub receiver? Is this Id is same as partition Key in Azure event hub Publisher?
What is Offset? ,What the use of it in azure event hub consumer?
Can I consume the message with out using consumer group?
Can I consume the message with single receiver?
What is the use of blob in event hub consumer? I want only view the message what ever I sent.
This article Event Hubs Overview should answer your questions in detail, but to summarize:
When you create a new Event Hub in the portal, you specify how many partitions you need. The Publisher hashes the partition key of an event to determine which partition to send the event to. An event hub receiver receives events from those partitions.
An event hub consumer tracks which events it has received by by using an offset into each partition. By changing the offset you can, for example, re-read events from a partition.
You must have at least one consumer group (there is a default one). Each consumer group has it's own view of the partitions (different offset values) that let it read the events from the partitions independently of the other consumer groups.
Typically, you have one receiver per partition to enable scale out. An event hub has between 8 and 16 partitions.
Offset values are managed by the client. You can checkpoint your latest position in each partition to enable you to restart at the latest event if the client restarts. The checkpoint mechanism writes the latest offset values to blob storage.

Resources