Understand the project structure

Completed

The following describes the highlighted sections of the project, which are available at the GitHub repository.

  • There are two modules:
    • CameraCaptureOpenCV
    • ImageClassifierService
  • The module.json file defines the Docker build process, the module version, and the container registry/image repository used during build and push. In this lab, the linked sample's module repository values use localhost:5000 because the next exercise starts a lab-only local registry. Those values work only when the IoT Edge runtime can reach that registry as localhost:5000. If your build computer and IoT Edge device are different hosts, use Azure Container Registry or another reachable registry host, update the module repository values before building, and configure device pull credentials. Updating the version number, pushing the updated module image to the registry, and deploying the generated deployment manifest for an edge device trigger the Azure IoT Edge runtime to pull the new module image.
  • The deployment.template.json file is the source template for the IoT Edge deployment manifest, not the per-module build metadata. The module.json files provide the Docker build settings and image repository values for each module; the build/deploy workflow combines those values with the deployment template and generates an architecture-specific manifest in the config folder. The deployment template/manifest declares which modules should be deployed, container create options and registry credentials, $edgeAgent and $edgeHub runtime settings, module desired properties, and message routes. The linked sample template currently contains older IoT Edge 1.1 runtime image tags; before you build or deploy in the next exercise, update the template to supported IoT Edge 1.5 LTS runtime images and set both $edgeAgent.properties.desired.schemaVersion and $edgeHub.properties.desired.schemaVersion to "1.1".
  • The template defines a route from the camera-capture module's output1 to IoT Hub through $upstream. Routes don't create messages by themselves: IoT Hub events appear only when module code sends device-to-cloud messages to output1. For the unmodified linked sample, local module logs and module health still verify module behavior even if no upstream events appear in IoT Hub.
  • The architecture-specific deployment manifest is generated from deployment.template.json in the config folder. For this lab, use the amd64 build path that the linked sample demonstrably supports for the exported classifier assets; the generated manifest is config\deployment.amd64.json. Deploy config\deployment.amd64.json, not deployment.template.json, because the template can contain placeholders and pre-build settings. The linked sample's modules/ImageClassifierService/module.json lists three platforms (amd64, arm32v7, arm64v8 — note the key is arm64v8, not arm64), while modules/CameraCaptureOpenCV/module.json lists only amd64 and arm64v8 (no arm32v7 platform for the camera module). Beyond the naming gap, modules/ImageClassifierService/Dockerfile.arm64v8 uses FROM arm32v7/python:3.7-slim and copies the cv-arm32v7/app assets, so it is functionally an arm32v7 build with no native arm64 classifier export. Don't select an Arm build/deployment path for this lab unless the sample repository is updated and tested for that target.
  • The version.py in the project root folder is a helper app you can run on your development machine that updates each module's version number. Useful as a change in the version number triggers Azure IoT Edge runtime to pull the updated module, and it is easy to forget to change the module version numbers.

Important

The linked sample repository is a learning sample. Do not build or deploy a generated manifest from the unmodified template. First update deployment.template.json to use the supported Azure IoT Edge 1.5 LTS runtime images, such as mcr.microsoft.com/azureiotedge-agent:1.5 and mcr.microsoft.com/azureiotedge-hub:1.5, instead of older IoT Edge 1.1 runtime image tags, and set both $edgeAgent.properties.desired.schemaVersion and $edgeHub.properties.desired.schemaVersion to "1.1". Before deploying, build the solution for amd64 so config\deployment.amd64.json contains the updated runtime image tags, schema versions, and module image references that the IoT Edge runtime can pull.

The illustration shows the project structure.