title | description | author | ms.service | services | ms.topic | ms.date | ms.author | ms.custom |
---|---|---|---|---|---|---|---|---|
include file |
include file |
robinsh |
iot-hub |
iot-hub |
include |
03/05/2019 |
robinsh |
include file |
Message routing enables sending telemetry data from your IoT devices to built-in Event Hub-compatible endpoints or custom endpoints such as blob storage, Service Bus Queues, Service Bus Topics, and Event Hubs. To configure custom message routing, you create routing queries to customize the route that matches a certain condition. Once set up, the incoming data is automatically routed to the endpoints by the IoT Hub. If a message doesn't match any of the defined routing queries, it is routed to the default endpoint.
In this 2-part tutorial, you learn how to set up and use these custom routing queries with IoT Hub. You route messages from an IoT device to one of multiple endpoints, including blob storage and a Service Bus queue. Messages to the Service Bus queue are picked up by a Logic App and sent via e-mail. Messages that do not have custom message routing defined are sent to the default endpoint, then picked up by Azure Stream Analytics and viewed in a Power BI visualization.
To complete Parts 1 and 2 of this tutorial, you perform the following tasks:
Part I: Create resources, set up message routing
[!div class="checklist"]
- Create the resources -- an IoT hub, a storage account, a Service Bus queue, and a simulated device. This can be done using the Azure portal, an Azure Resource Manager template, the Azure CLI, or Azure PowerShell.
- Configure the endpoints and message routes in IoT Hub for the storage account and Service Bus queue.
Part II: Send messages to the hub, view routed results
[!div class="checklist"]
- Create a Logic App that is triggered and sends e-mail when a message is added to the Service Bus queue.
- Download and run an app that simulates an IoT Device sending messages to the hub for the different routing options.
- Create a Power BI visualization for data sent to the default endpoint.
- View the results ...
- ...in the Service Bus queue and e-mails.
- ...in the storage account.
- ...in the Power BI visualization.
-
For Part 1 of this tutorial:
- You must have an Azure subscription. If you don't have an Azure subscription, create a free account before you begin.
-
For Part 2 of this tutorial:
- You must have completed Part 1 of this tutorial, and have the resources still available.
- Install Visual Studio.
- Have access to a Power BI account to analyze the default endpoint's stream analytics. (Try Power BI for free.)
- Have a work or school account for sending notification e-mails.
- Make sure that port 8883 is open in your firewall. The sample in this tutorial uses MQTT protocol, which communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work around this issue, see Connecting to IoT Hub (MQTT).
[!INCLUDE cloud-shell-try-it.md]