Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note
This is only supported in

...

4.0.7 or newer release of Azure Injector.

Prerequisites

...

  • Setting up an Azure storage account and storage container for message storage
  • Modifying the Azure Injector Module to connect to an existing Azure IoT Hub with proper 'content type' and 'content encoding' settings
  • Publishing live Tag tag data and events to the connected Azure IoT Hub
  • Viewing the data that has been routed to the Storage Container in Azure

Upon completion of this module tutorial you will have an Ignition Gateway with the Azure Injector module connected and publishing live Tag tag data to an Azure IoT Hub and being . Those messages will then be automatically routed and stored to in an Azure Storage Container.

Tutorial

Step 1: Make sure you have completed the Getting Started: Azure Injector Quick Start tutorial

...

Specify the Subscription, Resource Group, Storage account name, and Location as shown above. Leave the other fields default. Now click 'Review + Create' near the bottom of the screen. All of the other tab fields (under Networking, Data Protection, Advanced, and Tags) can be left default for the purposes of this example. However, if this is intended to run in production make sure to visit these tabs and set up the Storage Account appropriately for your use case and security needs. After creating the Storage accountAccount, you should see it on the main Storage Accounts page as shown below:

...

Now give it a name and also select the Storage Container that was created during Step 2 of this tutorial. Also, make sure to set the 'Encoding' type to JSON as shown above. Leave all other fields default. Finally click 'Create'. When the endpoint creation completes, you should see the created endpoint as shown below.

...

Step 4: Reconfigure Azure Injector to Support Message Based Routing

Now browse to the Ignition Gateway Web UI and to the Azure Injector Settings and finally to the 'Azure IoT Hubs'. You should see the 'Test Setting' that was created in the prerequisite tutorial as shown below.Image Added

Click the 'edit' button on the right for that setting to edit it. Then scroll down and click the 'Show advanced properties' checkbox near the bottom as shown below.

Image Added

Note the 'Content Type' and 'Content Encoding' fields. In order for Azure message routing to work, the 'Content Type' MUST be set to APPLICATION_JSON and the 'Content Encoding' should be set to UTF_8.

During the prerequisite tutorial a set of tags were created to publish to Azure IoT Hub. At this point, we will create some new tags that will be will be routed to the container based on the previous configuration that now exists in Azure. Because we created a message route that filtered on a Sparkplug Group ID of 'Routed Group' we should create a structure that includes this in the tag tree. So, expanding Expanding on the tag tree created previously, add a new Sparkplug Group, Edge Node, and Device folder structure with a single boolean tag along side the original structure created in the quickstart as shown below. Note for the message route in Azure to work properly, the Group ID MUST be 'Routed Group' as shown below.

...

Step 6: View the Data in the Azure Storage Container

At this point, the data should be flowing into the container. To view it, browse back to your Storage Account in the Azure portal. In the main panel is a 'Storage Explorer' option (shown below) which is in preview at the time of this writing (Feb 26, 2021). Click this link to open the Storage Explorer.

Image Added

After opening the Storage Explorer, you should see something similar to the following

Image Added

Under the 'BLOB CONTAINERS' there should be a link with your container as well a folder showing your IoT Hub name. Note it may take a few minutes for this data to appear even with everything configured properly. Once the IoT Hub name is present, double click it in the far right panel and click through the series of folders shown there. These folders represent the time at which various files were created. When you get to the final folder, you should see something similar to what is shown below in that the final leaf folder contains one or more JSON files.

Image Added

Select one of these files and download it. Upon opening with a text editor, you should see something similar to the following.

Image Added

If you scroll to the right, you should ultimately see the 'body' of the message. This is the raw message that was sent to Azure from the Azure Injector module. Each one of these messages represents a message that was sent from Azure Injector to IoT Hub.

Image AddedNote that all of the messages shown here are from the 'Routed Group'. This is because of how the Azure IoT Hub message route was configured. The 'routing query' is looking for a 'groupId' of 'Routed Group'. So, all messages from the original 'Tutorial Group' were ignored and not routed to the container.

Additional Resources