Installation using Azure IoT Edge

Losant’s Gateway Edge Agent (GEA) is available in the Azure Marketplace as an IoT Edge Module. This allows you to use Azure IoT Edge to install and manage the GEA container.

Azure IoT Edge and Losant Edge Compute provide complementary services that work together for a complete edge computing stack. While Losant provides the tools to implement and deploy logic via Edge Workflows, it does not provide the tools to manage the underlying GEA’s Docker container. Azure IoT Edge is designed to deploy and manage Docker containers. This means Losant manages the edge logic and Azure manages the underlying container.

Set Up Azure IoT Edge and Azure IoT Hub

Azure provides an excellent Quick Start for installing the IoT Edge Runtime on your device and configuring Azure IoT Hub. Please follow Azure’s instructions and continue once your device is available in your own Azure IoT Hub instance.

Common Problem: error when installing moby-engine. This likely due to your device already having Docker installed. You’ll have to uninstall Docker and try installing the Azure IoT Edge Runtime again.

Install and Configure the Losant Edge Compute IoT Edge Module

In your Azure portal, navigate to your IoT edge device and click the Set Modules menu item.

Azure IoT Edge Device Overview

Next, select the Add drop down and choose Marketplace Module.

Azure IoT Edge Add Marketplace Module

On the marketplace popup, search for Losant and select the Losant Edge Agent result.

Azure IoT Edge Search Losant

This will add an unsaved entry to this device’s list of modules named LosantEdgeCompute. Click this entry to configure the module.

Azure IoT Edge LosantEdgeCompute

Navigate to the Environment Variables tab and enter the ID of your Losant Edge Compute Device as well as the Access Key and Secret for that device. These are the credentials used to authenticate this device’s connection to Losant.

Azure IoT Edge Losant Environment Variables

This is the minimum configuration required for the Losant Edge Compute module. You can now click the Update button to close this configuration panel and then the Review + Create button to deploy this module to your device.

It may take several minutes to deploy, depending on your device’s processing power and connection speed. On a Raspberry Pi 3, it takes approximately 5-10 minutes. After refreshing the Azure portal, you will eventually see the module’s status set to Running.

Azure IoT Edge Module Running

You can confirm the container is running on the device itself by running docker ps at the command line:

Azure IoT Edge Module Docker ps

The final confirmation that your Gateway Edge Agent is successfully deployed is viewing the device connection status in the Losant portal.

Losant Device Connection Status

Additional GEA Configuration

The Gateway Edge Agent supports several configuration parameters that can be provided using environment variables. These are configured in Azure in the same place you defined the DEVICE_ID, ACCESS_KEY, and ACCESS_SECRET environment variables.

All available configuration parameters can be found on the Losant Edge Agent Docker Hub page.

Configuring the Docker Create Options

Azure supports the configuration of Docker Create Options through a JSON document. The most common use for this configuration is to expose communication ports from the container to the host.

Azure IoT Container Create Options

The following configuration is provided by default:

{
  "HostConfig": {
    "PortBindings": {
      "8080/tcp": [
        {
          "HostPort": "8080"
        }
      ]
    }
  }
}

This configuration exposes the port of the GEA’s built-in webserver. By default, the web server listens on port 8080 inside the container. This configuration exposes port 8080 from inside the container to the host, which is required to allow other devices on your network to access the webserver.

To use the GEA’s MQTT broker or UDP server, this configuration must be modified to expose the appropriate ports. The default port for the MQTT broker is 1883. UDP ports are configured as part of your UDP Trigger(s).

Available Image Versions

Not every version of the Gateway Edge Agent is available on the Azure Marketplace. The following list contains the currently available versions:

  • latest
  • latest-alpine
  • 1.20.0
  • 1.20.0-alpine

Alpine images are smaller in size and useful for storage-constrained devices. All images are multi-arch and support both ARM and x86 devices. Further details can be found on the Losant Edge Compute Docker Hub page.

Accessing Azure-Provided Runtime Configuration

The Azure IoT Edge Runtime defines several environment variables that can be accessed by your Edge Workflows. For example, the Azure ID of the current device is available on the IOTEDGE_DEVICEID environment variable.

The Gateway Edge Agent automatically places environment variables on every workflow’s payload at agentEnvironment. This allows you to use these values as part of your custom edge logic.

Azure IoT Edge Runtime Environment Variables

Was this page helpful?


Still looking for help? You can also search the Losant Forums or submit your question there.