In this blog I detail the procedure to separate the device messages that contain temperature alert. Once these are separated, they can be channeled to separate cloud storage and also trigger actions to intimate the user about the alert.


The messages with alert are sent to a critical queue and read from that. This is done as described in the Azure document


  1. First a Service Bus Messaging Namespace is created in Azure Portal as follows:
    1. Go to +New -> Enterprise Integration -> Service Bus. This shows the Create Namespace panel.
    2. .Here created a name space named esm-sb-ns.
  2. Then copied the connection string for this name space to text file.
  3. In this name space then created a Queue named esm-iot-critical-q.
  4. Then in the IoT Hub named esmiothub, created a custom endpoint with following attributes:
    1. Name: esm-critical-q-ep
    2. Type: Service Bus Queue
    3. Service Bus Namespace: esm-sb-ns
    4. Service Bus Queue: esm-iot-critical-q
  5. Then created a Route in the same IoT Hub with following attributes:
    1. Name: esm-iot-critical-route.
    2. Data Source: Device Messages
    3. Endpoint: esm-critical-q-ep
    4. Query String: TemperatureAlert="true"
  6. Then created a .Net Console app named vc_read_alerts. The code for which is shown in the screenshot below.

Code to Read Alerts



Then both vc_read_alerts and vc_device_live_data are run simultaneously. The STM unit was also powered up. It is expected that all messages with "No Alert" are to be picked up by vc_device_live_data and the messages with "Alert Occurred" will be picked up by the vc_read_alerts program. Unfortunately alert messages were not picked up by vc_read_alerts. This can be seen in the screenshot below. The upper part is the output of vc_device_live_data and the lower part is that of vc_read_alerts. I have created alert by moving the sensors to near a warm light bulb. This needs to be debugged.Console app - Read Alerts