Reader small image

You're reading from  The Azure IoT Handbook

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781837633616
Edition1st Edition
Right arrow
Author (1)
Dan Clark
Dan Clark
author image
Dan Clark

Dan Clark is a senior developer and data engineer specializing in Microsoft technologies. He is focused on learning new AI and data technologies and training others on how to best implement those technologies. He has worked as an Azure Technical Trainer (ATT)for Microsoft and has over 25 years of experience as a Microsoft Certified Trainer. Dan has published several books and numerous articles on Microsoft technologies. He is a regular speaker at various developer and database conferences and user group meetings and enjoys interacting with the Microsoft communities.
Read more about Dan Clark

Right arrow

Creating Message Routing

In the previous chapters, you have seen how to set up, deploy, and secure your IoT devices. You have also sent signals from devices to an IoT hub. Now that you can set up IoT systems, it is time to learn how to process these signals. One of the first steps in processing signals is to route them to various endpoints. As we embark on this exploration, you will discover the key principles behind efficient message routing, the customization options available to tailor communication pathways to your specific needs, and how to leverage message routing queries to gain deeper insights and control over your data flows. Additionally, we will delve into the transformative practice of message enrichment, where you will learn how to enhance your data payloads with valuable contextual information, opening the door to richer and more informed decision-making.

In particular, we will look at the following topics:

  • Message routing basics
  • Built-in endpoints
  • ...

Exploring the basics and overall process of message routing

In an IoT hub, message routing involves the process of directing and delivering messages between IoT devices and cloud-based services or other endpoints. The IoT hub acts as a central hub or intermediary that facilitates communication and data exchange in an IoT ecosystem. Here’s an overview of the message routing process:

  1. Device connectivity: IoT devices, such as sensors or actuators, establish a connection with the IoT hub. They can use various communication protocols, including Message Queuing Telemetry Transport (MQTT), Advanced Message Queuing Protocol (AMQP), or Hypertext Transfer Protocol (HTTP), to connect to the IoT hub over the internet or other supported networks.
  2. Message ingestion: The IoT hub receives messages from the connected devices. These messages can contain sensor data, device telemetry, commands, or other types of information.
  3. Routing rules: Within the IoT hub, you can define routing...

Common use cases for using the built-in endpoint in an IoT hub

The built-in endpoint in an IoT hub provides a convenient way to route messages from IoT devices to different backend systems or applications. Here are some common use cases for using the built-in endpoint in an IoT hub:

  • Telemetry data storage: IoT devices often generate large volumes of telemetry data. The built-in endpoint can be used to route telemetry messages to a storage system such as Azure Blob Storage or Azure Data Lake Storage for long-term storage and analysis.
  • Real-time analytics: The built-in endpoint can forward telemetry data to real-time analytics systems such as Azure Stream Analytics (ASA) or Azure Databricks. This enables you to perform real-time processing, aggregations, and analytics on incoming data.
  • Command and control: IoT Hub allows bidirectional communication with devices. The built-in endpoint can be used to receive command messages from backend systems or applications and route...

Common use cases for using custom endpoints in an IoT hub

Using a custom endpoint in an IoT hub offers additional flexibility and control over where messages from IoT devices are sent. Here are some use cases for using a custom endpoint in an IoT hub:

  • Custom data processing: By setting up a custom endpoint, you can route messages from IoT devices directly to your own backend systems for custom data processing. This enables you to implement specialized data processing logic, perform complex analytics, or integrate with existing enterprise systems.
  • Legacy system integration: If you have legacy systems or on-premises infrastructure that needs to consume IoT device data, a custom endpoint can be configured to forward messages to these systems. This allows you to seamlessly integrate IoT data into your existing workflows and applications.
  • Third-party service integration: IoT Hub’s custom endpoint can be used to integrate with third-party services or platforms that...

Message routing queries

In the context of an IoT hub, routing refers to the process of directing and forwarding incoming messages from IoT devices to different endpoints or destinations within the IoT ecosystem. IoT Hub is a cloud-based service that acts as a central hub for managing and communicating with many connected devices.

Routing in an IoT hub enables you to define rules and conditions based on the message content or device metadata and then automatically route the messages to appropriate endpoints. These endpoints can include other Azure services, custom applications, storage systems, databases, or even other IoT hubs.

Here’s a high-level overview of how routing works in an IoT hub:

  1. The device sends a message: An IoT device connected to the IoT hub sends a telemetry message, event, or state update to the hub.
  2. Routing rules: The IoT hub evaluates the routing rules defined by the user. These rules specify conditions and filters based on message properties...

Exploring message enrichment

Message enrichment in an IoT hub refers to the process of enhancing or augmenting incoming messages from IoT devices with additional information or metadata before they are routed or processed further. This enrichment can include adding contextual data, transforming the message format, or enriching the message payload with additional attributes.

IoT Hub provides a feature called message enrichments that allows you to configure rules to enrich messages as they pass through the hub. These rules can be defined based on specific criteria or conditions, and they enable you to modify messages by adding, updating, or deleting message properties or inserting custom data.

Here are a few common scenarios where message enrichment can be useful:

  • Adding metadata: You can enrich messages with additional metadata such as device properties, location information, or timestamp information. This metadata can provide context to the message and help in downstream...

Lab – using message enrichment and custom endpoints

Message routing within Azure IoT Hub serves as the conduit through which telemetry data from IoT devices is seamlessly channeled to an array of Azure services, including Blob Storage, Service Bus queues, Service Bus topics, and Event Hubs. Within the framework of IoT hubs, there exists a default, preconfigured endpoint that aligns seamlessly with Event Hubs. Furthermore, the system allows for the establishment of custom endpoints, coupled with the utilization of routing queries to precisely channel messages toward other Azure services. When a message arrives at the IoT hub, it is disseminated to all endpoints for which its routing queries are a match. In the event that a message fails to correspond with any of the defined routing queries, it is automatically directed toward the default endpoint.

In this lab, you will accomplish the following tasks:

  • Establish an IoT hub and dispatch device messages to it
  • Generate...

Summary

In this chapter, we dove into the world of Azure IoT Hub routing, exploring its capabilities, configuration options, and benefits. Azure IoT Hub routing is a powerful feature that allows users to efficiently route and process data generated by IoT devices, enabling seamless integration with downstream services and applications. IoT Hub routing acts as a central hub for data ingestion from multiple devices, providing a scalable and reliable platform for managing IoT data at scale.

We investigated the various routing capabilities offered by Azure IoT Hub. We discussed message routing, which allows users to define routing rules based on message properties, ensuring that data is sent to the appropriate endpoints. We also explored the flexibility of message routing, including the ability to route messages based on device properties, custom message properties, or even message content. Then, we covered message enrichment, whereby users can enrich messages with additional information...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Azure IoT Handbook
Published in: Dec 2023Publisher: PacktISBN-13: 9781837633616
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Dan Clark

Dan Clark is a senior developer and data engineer specializing in Microsoft technologies. He is focused on learning new AI and data technologies and training others on how to best implement those technologies. He has worked as an Azure Technical Trainer (ATT)for Microsoft and has over 25 years of experience as a Microsoft Certified Trainer. Dan has published several books and numerous articles on Microsoft technologies. He is a regular speaker at various developer and database conferences and user group meetings and enjoys interacting with the Microsoft communities.
Read more about Dan Clark