Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

intel/edge-to-azure-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PROJECT NOT UNDER ACTIVE MANAGEMENT

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

Contact: webadmin@linux.intel.com DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

This project has been identified as having known security escapes.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

Contents

Edge-to-Cloud Bridge for Microsoft Azure* Introduction

Edge-to-Cloud Bridge for Microsoft Azure* service connects to publishers (MQTT Broker, EII Message Bus) and sends data to Azure IOT Hub. This repository contains the source code for Edge-to-Cloud Bridge for Microsoft Azure* service. For information on how to build the use case, refer to the Get Started guide.

NOTE: Currently, the microservice works in an open network only.

Prerequisites

  • MQTT Port 1883, 8080, 8554 is not used. (for non-EII runtime)
  • Azure IoT Edge Runtime
  • Azure CLI

Building the Image

  • To build the base image, run the following command docker-compose -f docker-compose-build.yml build edge_to_azure_bridge

  • You can download the prebuilt container image for Edge-to-Cloud Bridge for Microsoft Azure* service from Docker Hub

Running in EII Mode

NOTE:

  1. The independent build of the EdgeToAzureBridge service can be done as per above section
  2. As EdgeToAzureBridge service is being deployed as Azure IoT modules along with other EII modules as a use case solution, independent deployment of EdgeToAzureBridge service with or without Config Manager Agent service dependency is not been enabled.
  • Refer to README for using Edge-to-Cloud Bridge for Microsoft Azure* service in EII mode with other EII supported modules.

Running the Microservice

The Edge-to-Cloud Bridge for Microsoft Azure* service runs as an Azure Module. You need to set up your development system for using the microservice with Azure IOT runtime.

Development system Setup :

Tutorial 1 - Sending Data using Edge-to-Cloud Bridge for Microsoft Azure* Service

The microservice connects to the MQTT broker and listens to the messages incoming to the topics defined in the configuration file (mosquitto.json). Once the microservice receives the data on these topics, it validates the message with a schema (schema.json) and sends the data to Azure IOT Hub.

The default schema is defined below.

{
    "properties": {
      "objects": {
        "description": "The unique identifier for a inference metadata.",
        "type": "array"
      }
    },
    "required": [ "objects" ]
  }

The message published to the broker in the given JSON schema will be upstreamed to the Azure IoT Hub.

  • The MQTT publisher can publish the payload to the Broker as per the schema in the JSON format below:
  {
    "objects":["Payload1", "Payload2"]
  }

Follow the steps to setup the service :-

  • Update the Deployment manifest file (config/deployment.template.json) with the absolute path to the config files.
<snip>

[\"EDGE_TO_AZURE_BRIDGE_RESOURCES/mosquitto/:/mosquitto/config\"]

<snip>
  • The below command will replace the placeholder tag in the configuration with the absolute path to the Resources folder.
sed -i "s^EDGE_TO_AZURE_BRIDGE_RESOURCES^$PWD^g" config/deployment.template.json
  1. Deploy the manifest file using the command below
az iot edge set-modules -n <azure-iot-hub-name> -d <azure-iot-edge-device-name> -k config/deployment.template.json
  1. Check the deployment status using
sudo iotedge list
  • Test will send a message to the service.

  • The MQTT publisher can publish the payload to the Broker as per the schema in the JSON format below:

  {
    "objects":["Payload1", "Payload2"]
  }
  • There are multiple ways to publish data to the Broker :

    • You can use any OpenSource MQTT Client to publish data to the Broker (example MQTTExplorer)

    • From your code, using any MQTT client SDK example : Python , JavaScript

  • Monitor Azure IOT Hub Data

az iot hub monitor-events --output table --device-id <Device ID> --hub-name <IoT HUB name>

Tutorial 2 - Changing Topics and Message Schema for Edge-to-Cloud Bridge for Microsoft Azure* Service

  • For changing the topics to which your application publishes the messages, update the mosquitto.json file with the list of topics.

  • For example, lets assume the application publishes to camera1 topic, we can update the configuration file as below:

{
    "topics": ["camera1"],
    "BrokerHost": "MQTTBroker",
    "BrokerPort": 1883
}
  • For changing the message schema, update the schema.json file

  • For example, lets assume the application publishes location and people count to the topic as below:-

{
  
  "location": "SB_2_1",
  "people_count": 3

}
  • We can update the schema to validate the messages coming to the service.
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
      "location": {
        "description": "Location of the camera",
        "type": "string"
      },
      "people_count": {
        "description": "No of people",
        "type": "integer"
      }
    },
    "required": [ "location", "people_count"]
  }
  • To learn more about defining the schemaFollow, use this link
  1. To update the service with these changes restart the service.
sudo iotedge restart EdgeToAzureBridge
  1. Send the message with the above schema and to the defined topic to verify.

Tutorial 3 - Sending the Data from Edge Video Analytics Microservice to Azure IOT Hub using Edge-to-Cloud Bridge for Microsoft Azure* Service

  1. Install the Video Analytics Use Case. For information on how to build the use case, please refer to the Get Started guide.

  2. Download the required models as documented here

  3. Once the models are downloaded, update the Deployment manifest file (config/deployment_evam.template.json) with the location of the Edge Video Analytics Resources folder.

<snip>

[\"EVAM_RESOURCES/models:/app/models\",\"EVAM_RESOURCES/pipelines:/app/pipelines\

<snip>
  1. Run the below command
sed -i "s^EVAM_RESOURCES^<Path to EVAM Resources>^g" config/deployment_evam.template.json
  • Example:
sed -i "s^EVAM_RESOURCES^/home/intel/public/video_analytics/Video_Analytics_2021.4.2/Edge_Video_Analytics_Resources^g" config/deployment_evam.template.json
  1. From the Edge to Azure Resources folder, update the deployment template with the absolute path to the configuration files
<snip>

{\"Binds\":[\"EDGE_TO_AZURE_BRIDGE_RESOURCES/mosquitto.json:/app/mosquitto.json\"

<snip>
  1. Run the below command
sed -i "s^EDGE_TO_AZURE_BRIDGE_RESOURCES^$PWD^g" config/deployment_evam.template.json
  1. Deploy the manifest file using the command below
az iot edge set-modules -n <azure-iot-hub-name> -d <azure-iot-edge-device-name> -k config/deployment_evam.template.json
  1. Check the deployment status using
sudo iotedge list
  1. Start a new pipeline and monitor Azure IoT Hub data. (Update the SYSTEM_IP_ADDRESS below, before running the pipeline)
curl --location --request POST 'http://localhost:8080/pipelines/object_detection/person_vehicle_bike' --header 'Content-Type: application/json' --data-raw '{
  "source": {
      "uri": "https://github.com/intel-iot-devkit/sample-videos/raw/master/person-bicycle-car-detection.mp4?raw=true",
      "type": "uri"
  },
  "destination": {
      "metadata": {
        "type": "mqtt",
        "host": "<SYSTEM_IP_ADDRESS>:1883",
        "topic": "vaserving"
      }
  }
}
'
  1. Monitor Azure IOT Hub Data
az iot hub monitor-events --output table --device-id <Device ID> --hub-name <IoT HUB name>

To learn more about Azure IoT Hub visit this link.

Licensing Info

The code in this repository is MIT-licensed. More information can be found in the license file. This project uses Intel EII libraries during building, which are not MIT-licensed. See those libraries' details for information on their licensing and conditions.