Azure IoT Hub message enrichment simplifies downstream processing of your data

Posted on May 30, 2019

Program Manager, Azure IoT

We just released a new capability that enables enriching messages that are egressed from Azure IoT Hub to other services. Azure IoT Hub provides an out-of-the-box capability to automatically deliver messages to different services and is built to handle billions of messages from your IoT devices. Messages carry important information that enable various workflows throughout the IoT solution. Message enrichments simplifies post-processing of your data and can reduce costs of calling device twin APIs for information. This capability allows you to stamp information on your messages, such as details from your device twin, your IoT Hub name or any static property you want to add.

Diagram of IoT Hub workflow and message routing

A message enrichment has three key elements, the key name for the enrichment, the value of the enrichment key, and the endpoints that the enrichment applies to. Message enrichments are added to the IoT Hub message as application properties. You can add up to 10 enrichments per IoT Hub for standard and basic tier IoT Hubs and two enrichments for free tier IoT Hub. Enrichments can be applied to messages going to the built-in endpoint, messages that are routed to the built-in endpoint, or custom endpoints such as Azure blob storage, Event Hubs, Service Bus Queue, and Service Bus topic. Each enrichment will have a key that can be set as any string, and a value that can be a path to a device twin (e.g. $twin.tag.field), the IoT Hub sending the message (e.g. $iothubname), or any static value (e.g. myapplicationId).

You can also use the IoT Hub Create or Update REST API, and add enrichments as part of the RoutingProperties. For example:

"routing": {
             "enrichments": [
                   {
                         "key": "appId",
                         "value": "myApp",
                         "endpointNames": ["events"]
                   },
                   {
                         "key": "Iot-Hub-Name",
                         "value": "$iothubname",
                         "endpointNames": ["events"]
                   },
                   {
                         "key": "Device-Location",
                         "value": "$twin.tags.location",
                         "endpointNames": ["events"]
                   }
             ],
             "endpoints": {
                 "serviceBusQueues": [],
                 "serviceBusTopics": [],
                 "eventHubs": [],
                 "storageContainers": []
             },
             "routes": [{
                 "name": myfirstroute",
                 "source": "DeviceMessages",
                 "condition": "true",
                 "endpointNames": [
                     "events"
                 ],
                 "isEnabled": true
             }],
             "fallbackRoute": {
                 "name": "$fallback",
                 "source": "DeviceMessages",
                 "condition": "true",
                 "endpointNames": [
                     "events"
                 ],
                 "isEnabled": true
             }
         }

This feature is available for preview in all public regions except East US, West US, and West Europe. We are excited for you to try this capability and build more streamlined IoT solutions for your business. Try this tutorial to get started.

We would love to hear more about your experiences with the preview and get your feedback! Are there other capabilities in IoT Hub that you would like to see? Please continue to submit your suggestions through the Azure IoT User Voice forum.