Convert your docker-compose Project to Azure IoT Edge Solution

Xin Shi

If you are a container expert, you may want to port your existing compose application to Azure IoT Edge. We are glad to introduce iotedge-compose to help convert your docker-compose project to Azure IoT Edge. Let us see how it works.

Prerequisites

Install the Tool and Convert a Sample Project

  1. Install the tool by running the following command
    pip install iotedge-compose
  2. Clone a sample docker-compose project
    git clone https://github.com/shizn/iotedge-compose-hello-world.git
  3. Run the sample application
    cd iotedge-compose-hello-world.git/app
    docker-compose up
  4. Enter http://localhost:5000/ in a browser to see the application running
  5. Press CTRL+Z or run docker-compose down in the terminal to stop the sample app.
  6. Convert this compose app project to IoT Edge app project by running the following command
    cd ..
    iotedge-compose -t project -i app/docker-compose.yml -o app-edge

Build and deploy converted project to IoT Edge device

Now you should see an app-edge folder in the root folder, this folder is the converted Azure IoT Edge project.

  1. Open app-edge project with VS Code
    code app-edge
  2. Update the .env file with your Azure Container Registry info.
  3. Update the repository URL in module.json
  4. Login your docker registry with docker CLI and then click Build and Push the IoT Edge Solution in the context menu of deployment.template.json
  5. Create a deployment against your IoT Edge device id in Azure IoT Hub explorer with config/deployment.amd64.json file. After a few seconds, you can see the module icon showing in the treeview. (The demo app does not include Azure IoT Device SDK, so both the web and redis module cannot return module status)
  6. If you can access the IoT Edge device via public IP with port 5000 allowed, the demo page can be visited in your browser with http://<IoTEdgeDeviceAddress>:5000/

Summary

This blog walks you through the basic usage of the iotedge-compose tool with a hello world application. You can check the iotedge-compose tool page or the sample repo readme to learn more. Send your feedback to vsciet@microsoft.com and let us know your feedback!

 

0 comments

Discussion is closed.

Feedback usabilla icon