0
votes

currently I am trying to read the messages that are in the Azure IoT Hub, without using an azure stream analytics. Our Backend System should read the messages from the Iot Hub and we don't use an Event Hub.

During my research through the azure documentation (https://github.com/Azure/azure-iot-sdk-java) I found a java iot sdk, but there is no sample, which "just" reads the message. They always route the messages to a service bus or something else.

Is there any solution, which reads the messages in the IoT Hub for a Backend System without routing the messages?

Thanks!

4
See docs.microsoft.com/en-us/azure/event-hubs/… on how to use the data using an EventProcessorHost.Peter Bons

4 Answers

1
votes

Event Host Processor (EHP) is the way to read messages from IOT Hub. Basically IOT Hub is wrapper of old azure event hub (Although event hub is still separate component in azure). You can use EHP events to receive messages of IOT Hub.

Other option is reading data through device topic. Here is more info for this: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support

1
votes

I can recommend Azure Function App with Event Hub Trigger (written either in C#, F# or JavaScript) that enables receiving all messages sent to the Azure IoT Hub:

enter image description here

You can connect this trigger with your Azure IoT Hub:

enter image description here

enter image description here

I have applied this approach in my project - I attach architecture below. Azure Function App is connected with Azure IoT Hub with Event Hub Trigger. Once there is any data received by IoT Hub, it is passed to the Function App. Then this data is saved in the Azure Table Storage:

enter image description here

I described step by step integration process in my article - please see Azure Function IoTHubTrigger section:

https://daniel-krzyczkowski.github.io/Motion-detector-automatic-SMS-alerts/

There is a link to another project which presents the whole solution how to read data from the IoT Hub, save it in the Table Storage and retrieve it by backend API:

https://daniel-krzyczkowski.github.io/Micrososft-Azure-Sphere-connected-with-Azure-cloud-services/

0
votes

There's a tutorial at https://docs.microsoft.com/azure/iot-hub/iot-hub-java-java-process-d2c that shows a couple of ways to read device-to-cloud messages from your IoT Hub.

IoT Hub can deliver device-to-cloud messages to your back-end app through one or more service-facing endpoints. The default service-facing endpoint is Event Hubs-compatible, so you can use anything that can talk to an Event Hub (such as the Event Processor Host or Stream Analytics) to read these messages.

Routing within IoT Hub lets you route device-to-cloud messages to alternative endpoints (such as a Service Bus queue or topic): https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-read-custom.

0
votes

You can use an Azure Function in your Azure Lite-Stream Pipeline like is shown in the following screen snippet:

LiteStreamPipeline