본문 바로가기
🐳Azure

Getting Started with Azure IoT Hub -3

by 주입식교육의폐해 2025. 9. 10.

 

 










 

 

 

 

We will learn how to set up routing from IoT Hub to Service Bus and configure email alerts using Logic Apps.

To detect equipment anomalies, messages with specific values are sent from IoT Hub to a queue in Azure Service Bus. Using Logic Apps, the queue is checked every three minutes, and if there is content in the queue, that content is sent by email.

The table of contents is as follows.

 




▶Creating an Azure Service Bus namespace and queue
▶ Adding an IoT Hub user endpoint
▶ Creating Logic Apps
▶ Verifying the results


 

 

 


 

 

 

1. Create an Azure Service Bus namespace and queue

 


Search for Azure Service Bus in the Azure Portal and click on it.

Click Add and select the resource group, namespace name, location, and tier. In this exercise, we will use the basic tier.

Click Queues in the menu of the created namespace to create a queue as follows.

 

 

 

 

 

 

 


 

 

 

 

2. Add an IoT Hub user endpoint

 

 


▶ Click Message Routing in the IoT Hub menu.

▶Click Add Endpoint and select Service Bus Queue.

▶Enter the endpoint name and select the Service Bus namespace and queue you created earlier.

▶Return to the Add Route window, specify the name and endpoint, and select Device Remote Analytics Messages as the data source.

▶Enter the routing query. Using the default value will send all messages to the Service Bus queue. Set it to true for testing to send all messages to the queue.

 

 

 

 

 

 

 

▶Check the routing results. You can see that messages are being sent to the storage account and Azure Service Bus queue, which are the endpoints you set up in Getting Started with Azure IoT Hub -1.

 

 

 

 


 

 

 

 

 

 

 

 

 

3. Create Logic Apps

 

 


Use Logic Apps to send an email containing the message when there is a message in the Service Bus Queue.

Search for Logic Apps in the Azure Portal and select it.

Click +Add to select the resource group, logic app name, and location, and turn off Log Analytics.

Once the Logic App is created, click Logic App Designer in the menu.

Select the trigger for when a message is received from the Service Bus queue.

Click Continue to select the Service Bus queue and specify the interval at which to check the queue. By default, the queue is checked every 3 minutes.

 

 

 

 

 

 

 

 

♥Note: You can also modify the values of the frequency and interval variables by clicking View Code. ♥

 

 

 

 

 

♥ Add a step and select Send Outlook Mail. (Supports Slack, Outlook, Gmail, etc. as messengers.)

♥ Log in to Outlook and configure the detailed settings.

♥ Enter the Service Bus content in the body as shown in the figure below.

 

 

 

 

♥ Warning: If you have set all messages to be stored in the queue, you may receive a mail bomb. ♥

 

 

 

 


 

 

 

In the last three posts, we learned how to create an IoT hub and send data to various endpoints. Please also refer to the architecture that links the IoT hub with various PaaS services in Azure IoT Architecture.

반응형