Automatically translate this page?
25 February, 2021

Routing your telemetry data in Azure

Exploring the ways to handle the parsed messages from flespi using various Azure IoT services.

Microsoft Azure is an enterprise-level cloud ecosystem offering versatile services that enable the creation of cutting-edge solutions for most business domains. As a communication hub, flespi can serve as a source of normalized telemetry data for Azure services. The paths the incoming data will follow inside Azure are many and diverse. 

In this article, we will show how to forward telemetry messages containing the position data into the Azure storage and trigger the logic app scenario with the preconfigured action when the position gets into the specific geofence.

Establish communication with Azure IoT

First thing to do is to direct the parsed messages from flespi to Azure. We have a detailed step-by-step guide on getting your telemetry data from flespi into the Azure IoT hub.

Important note: make sure to check the “replace dots” option in the azure_iot stream configuration to be able to correctly refer to parameters in message routing expressions.

Configure message routing

Now that the telemetry data comes to Azure, we can configure the routing.

Message routing makes decisions based on the logical expressions on which messages should go to which Azure services.

At this step, we can define which messages we want to forward to a particular endpoint. To do so, navigate to the Message routing section in the left-side menu and click the Add button to create a new route:

azure message routing add

Forward telemetry to Azure storage

As we decided above, messages with position data (latitude and longitude) will end up in the Azure storage container (create one if needed):

azure routing new route

The condition is straightforward and simply checks for the presence of position_latitude and position_longitude parameters in the message.

The messages meeting the condition will be saved to the proper folder in your Azure storage account (more on storage options here):

azure storage account json files

Now you can work with these JSON files accordingly to accomplish the tasks in front of you.

Trigger action with Azure logic app

If the message contains a specific parameter we can initiate a certain action (or sequence of actions) in the Azure logic app.

In our case we check for the parameter geofence_id and instruct Azure to send a notification to the queue in the Azure service bus (details here):

azure routing to queue bus

Then the Azure logic app (details here) will read from the queue and trigger action defined in the scenario:

azure logic app designer scenario

What our logic app does is extracts the device_id parameter from the message and sends an HTTP PUT request to flespi to activate the “output1” output on the given device in our flespi account. The output can be connected to the engine cutoff relay (then the vehicle will stop), to the speaker (then a voice message will play), to the cargo truck door lock (then the doors will open once the truck approaches the warehouse), whatnot. 

You can see the status of all runs of the logic app on its Overview page:

azure logic app run status

Logic apps support a number of versatile scenarios. You can, for instance, send an email each time the device enters the geofence. We gave you the idea, you will come up with a specific implementation when you have a task at hand.

***

Microsoft Azure is such a multifaceted product that you can establish communication with it in multiple ways. Above we suggested the options via Azure storage and logic apps. You can also take a look at the case involving Cosmos DB.