NILESH
NILESH

Reputation: 55

UI based Custom module gets deployed but vanishes from set module after running successfully

I am using Azure IoT hub and deploying one custom modules to an edge device. out of 5 modules 4 are looking good. one of them disappears after deploying successfully in Set Modules area.

This module is nothing but a C++ executable with UI which we are deploying as container in IoT edge device

Problem: UI based Customer module gets deployed but vanishes from set module after running successfully.

Setup: Ubuntu 22.04.

Runtime: Docker and Azure IoT Edge Runtime

Installed: x11 and x Server running as our container based exe has UI to display

Steps to reproduce:

I am performing below steps to reproduce the problem.

  1. In IoT hub >> click on Set Modules >> Click on Add IoT edge module

  2. specify module name and container image URL

    1. Environment Settings: Add DISPLAY with value :0

    2. CreateOptions

      {
        "HostConfig": {
          "Binds": [
            "/dev/mem:/dev/mem",
            "/dev/gpiomem:/dev/gpiomem"
          ],
          "Mounts": [
            {
              "Source": "/dev",
              "Target": "/dev",
              "Type": "bind"
            },
            {
              "Source": "/tmp",
              "Target": "/tmp",
              "Type": "bind"
            },
            {
              "Source": "/tmp/.X11-unix",
              "Target": "/tmp/.X11-unix",
              "Type": "bind"
            }
          ],
          "NetworkMode": "host",
          "Privileged": true
        },
        "Env": [
          "DISPLAY=:0"
        ],
        "NetworkingConfig": {
          "EndpointsConfig": {
            "host": {}
          }
        },
       }
      

3. Now this gets deployed to edge device successfully. and I can see the UI on edge device running.

on Azure portal on IoT hub, I can see module running

enter image description here

Now if I go to Set Modules, I am expecting it is listed there. but this module is not visible.

I am deploying other modules and those are visible all the time but not this specific module.

Any help will be appreciated.

I am looking looking forward to see the custom module in set modules list same as all other modules agent and hub can be seen.

Upvotes: 0

Views: 56

Answers (1)

Sampath
Sampath

Reputation: 3639

The main reason the custom module gets deployed but vanishes from the "Set Modules" section after running successfully is due to the specification in the deployment manifest being set to "no". This issue occurs when the image is not properly configured or when there are issues with the Privileged mode, routes, or binding sensitive host paths.

Refer to this MSDOC to develop Azure IoT Edge modules using Visual Studio Code.

The key change here is how the deployment manifest is structured to include the custom module, similar to the edgeAgent and edgeHub modules. This ensures that the module's configuration is correct in terms of its properties and mount points.

Below is a sample of an IoT Edge custom module using a deployment manifest for the SimulatedTemperatureSensor module:

{
  "content": {
    "modulesContent": {
      "$edgeAgent": {
        "properties.desired": {
          "schemaVersion": "1.1",
          "runtime": {
            "type": "docker",
            "settings": {
              "minDockerVersion": "v1.25",
              "loggingOptions": "",
              "registryCredentials": {}
            }
          },
          "systemModules": {
            "edgeAgent": {
              "type": "docker",
              "settings": {
                "image": "mcr.microsoft.com/azureiotedge-agent:1.5",
                "createOptions": "{}"
              }
            },
            "edgeHub": {
              "type": "docker",
              "status": "running",
              "restartPolicy": "always",
              "settings": {
                "image": "mcr.microsoft.com/azureiotedge-hub:1.5",
                "createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
              }
            }
          },
          "modules": {
            "SimulatedTemperatureSensor": {
              "version": "1.0",
              "type": "docker",
              "status": "running",
              "restartPolicy": "always",
              "settings": {
                "image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.5",
                "createOptions": "{}"
              }
            }
          }
        }
      },
      "$edgeHub": {
        "properties.desired": {
          "schemaVersion": "1.1",
          "routes": {
            "upstream": "FROM /messages/* INTO $upstream"
          },
          "storeAndForwardConfiguration": {
            "timeToLiveSecs": 7200
          }
        }
      },
      "SimulatedTemperatureSensor": {
        "properties.desired": {
          "SendData": true,
          "SendInterval": 5
        }
      }
    }
  }
}

To deploy the deployment manifest, use the following Azure CLI command: az iot edge set-modules --device-id [device id] --hub-name [hub name] --content [file path] to deploy deployment manifest.

Refer to this MSDOC for the full deployment manifest and detailed steps.

UI Steps:

Login azure UI>> IoT hub >> click on Set Modules >> Click on Add IoT edge module.

I have added a sample simulated temperature image with the IoT module name SimulatedTemperatureSensor for the IoT Edge custom module using the image URI mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:latest. Additionally, I added a route named SimulatedTemperatureSensorToIoTHub that sends all messages from the simulated temperature module to the IoT Hub with the value FROM /messages/modules/SimulatedTemperatureSensor/* INTO $upstream.

Azure Iot edge logging

Upvotes: 0

Related Questions