Deploying IoT Edge Modules

This document provides a comprehensive guide to deploying and managing modules on your Azure IoT Edge devices. Learn how to create deployment manifests, target specific devices, and monitor the status of your deployments.

Tip: Understanding the concepts of IoT Edge deployments is crucial for orchestrating your edge workloads effectively.

What are IoT Edge Deployments?

An IoT Edge deployment is a set of instructions that tell an IoT Edge device what modules to run, how to configure them, and the desired properties for the module twins. Deployments allow you to manage modules at scale across your fleet of IoT Edge devices.

Key components of a deployment include:

Creating a Deployment Manifest

A deployment manifest is a JSON file that defines the modules to be deployed, their configurations, and routing information. You can create these manifests using the Azure portal, Azure CLI, or programmatically.

Example Deployment Manifest (deployment.json):

{
    "content": {
        "modulesContent": {
            "$edgeAgent": {
                "properties.desired": {
                    "schemaVersion": "1.0",
                    "runtime": {
                        "type": "docker",
                        "settings": {
                            "minDockerVersion": "v1.25"
                        }
                    },
                    "systemModules": {
                        "edgeAgent": {
                            "type": "docker",
                            "version": "1.0",
                            "env": {}
                        },
                        "edgeHub": {
                            "type": "docker",
                            "version": "1.0",
                            "status": "running",
                            "restartPolicy": "always",
                            "env": {
                                "experimentalFeatures.propertylist": " 1 ",
                                "MqttBroker.Property.MaxTopicLength": "128",
                                "MqttBroker.Property.MaxMessagesPerConnection": "100",
                                "MqttBroker.Property.MaxConnectionsPerIpAddress": "100"
                            }
                        }
                    },
                    "modules": {
                        "tempSensor": {
                            "version": "1.0",
                            "type": "docker",
                            "env": {},
                            "status": "running",
                            "restartPolicy": "always"
                        },
                        "azureIotHubModule": {
                            "version": "1.0",
                            "type": "docker",
                            "status": "running",
                            "restartPolicy": "always",
                            "env": {}
                        }
                    }
                }
            },
            "tempSensor": {
                "properties.desired": {
                    "temp": 25,
                    "interval": 5000
                }
            }
        },
        "registryCredentials": {
            "registryA": {
                "username": "your_registry_username",
                "password": "your_registry_password",
                "address": "your_registry_address.azurecr.io"
            }
        }
    },
    "deploymentProperties": {
        "deploymentPriority": 0,
        "metrics": {},
        "targetCondition": "tags.environment='production'"
    }
}

Types of Deployments

There are two main types of deployments:

Creating and Managing Deployments in Azure Portal

The Azure portal offers a user-friendly interface for creating and managing IoT Edge deployments:

  1. Navigate to your IoT Hub.
  2. Select Automatic device management from the left-hand menu.
  3. Click + Create to start a new deployment.
  4. Deployment type: Choose between Edge Managed or IoT Edge module.
  5. Deployment configuration: Upload your deployment manifest or configure modules directly.
  6. Target devices: Specify the devices or device groups to target using tags.
  7. Add metrics (optional): Define custom metrics for monitoring.
  8. Review + create: Finalize and create your deployment.

Deploying Custom Modules

To deploy your own custom modules, you'll need to:

  1. Containerize your application using Docker.
  2. Push the container image to a container registry (e.g., Azure Container Registry).
  3. Reference the image URI and credentials in your deployment manifest.
Note: Ensure that the IoT Edge agent on your device can pull the container image from the specified registry. Authentication is typically handled via registry credentials in the deployment manifest.

Deployment Priorities and Labels

When multiple deployments target the same device, the deployment with the highest priority (a lower integer value indicates higher priority) takes precedence. Labels can be used to group and organize deployments.

Monitoring Deployments

Monitor the status of your deployments to ensure modules are running correctly on your edge devices.

Troubleshooting Deployments

Common issues include:

Refer to the IoT Edge agent and IoT Edge hub logs on the device for detailed error information.

Related Topics