Read Azure IoT Hub device-to-cloud messages from the built-in and custom endpoints

Jun Han

Jun

IoT Hub Message Routing enables users to route device-to-cloud messages to service-facing endpoints. An IoT hub has a default built-in endpoint. You can create custom endpoints to route messages to by linking other services in your subscription to the hub. IoT Hub currently supports Azure Storage containers, Event Hubs, Service Bus queues, and Service Bus topics as custom endpoints. During development and operation, developers would want to monitor the device-to-cloud messages to see whether the Azure IoT application is working well. In this article, we will go through how to read device-to-cloud messages from the built-in and custom endpoints.

Reading from Built-in-endpoint

By default, messages are routed to the built-in service-facing endpoint (messages/events) that is compatible with Event Hubs. This endpoint is currently only exposed using the AMQP protocol on port 5671. With the Azure IoT Hub Toolkit Visual Studio Code, you could easily read device-to-cloud messages from the built-in endpoint. If you are using Visual Studio, you could also use Cloud Explorer to monitor device-to-cloud messages.

Reading from Azure Storage containers

IoT Hub supports writing data to Azure Blob Storage in the Apache Avro as well as JSON format. To read the data in Azure Storage containers, the easiest way is to use Azure Storage Explorer. You could also use the List Blobs API to enumerate the list of blobs.

Reading from Event Hubs

Apart from the built-in-Event Hubs compatible endpoint, you can also route data to custom endpoints of type Event Hubs. You could choose you favorite programming languages to receive events from Azure Event Hubs.

Reading from Service Bus queues

Service Bus queues used as IoT Hub endpoints must not have Sessions or Duplicate Detection enabled. If either of those options are enabled, the endpoint appears as Unreachable in the Azure portal. You could choose you favorite programming languages to receive messages from the queue.

Reading from Service Bus topics

Similar to Service Bus queues, Service Bus topics used as IoT Hub endpoints must not have Sessions or Duplicate Detection enabled. If either of those options are enabled, the endpoint appears as Unreachable in the Azure portal. You could choose you favorite programming languages to receive messages from the subscription.

 

For more information about tooling for Azure IoT Hub in Visual Studio Code, you could checkout the Wiki page of Azure IoT Hub Toolkit, we also have added a FAQ page to collect common questions from Azure IoT Hub developers.

 

Jun Han
Jun Han

Software Engineer II, Visual Studio IoT Tooling

Follow Jun   

No Comments.