Convert your docker-compose Project to Azure IoT Edge Solution
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.
- Make sure Docker Desktop is running on your system before using this tool.
- Python version >= 3.6.0 and Pip.
- Visual Studio Code and Azure IoT Tools for VS Code.
- Necessary Azure resources when developing Azure IoT Edge (IoT Hub with an IoT Edge device ID and Azure Container Registry)
Install the Tool and Convert a Sample Project
- Install the tool by running the following command
1pip install iotedge-compose
- Clone a sample docker-compose project
1git clone https://github.com/shizn/iotedge-compose-hello-world.git
- Run the sample application
12cd iotedge-compose-hello-world.git/appdocker-compose up
- Enter http://localhost:5000/ in a browser to see the application running
- Press CTRL+Z or run docker-compose down in the terminal to stop the sample app.
- Convert this compose app project to IoT Edge app project by running the following command
12cd ..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.
- Open app-edge project with VS Code
- Update the .env file with your Azure Container Registry info.
- Update the repository URL in module.json
- 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
- 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)
- 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/
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 firstname.lastname@example.org and let us know your feedback!