The IoT Edge Dev Tool greatly simplifies Azure IoT Edge development down to simple commands driven by environment variables.
- It gets you started with IoT Edge development with the IoT Edge Dev Container and IoT Edge solution scaffolding that contains a default module and all the required configuration files.
- It speeds up your inner-loop dev (dev, debug, test) by reducing multi-step build & deploy processes into one-line CLI commands as well as drives your outer-loop CI/CD pipeline. You can use all the same commands in both stages of your development life-cycle.
For the absolute fastest way to get started with IoT Edge Dev, please see the Quickstart section below.
For a more detailed overview of IoT Edge Dev Tool including setup and commands, please see the Wiki.
To set up development machines manually instead of using the IoT Edge Dev Container, please see the Manual Development Machine Setup Wiki.
This quickstart will run a container, create a solution, setup Azure resources, build and deploy modules to your device, setup and start the IoT Edge simulator, monitor messages flowing into IoT Hub, and finally deploy to the IoT Edge runtime.
The only thing you need to install is Docker. All of the other dev dependencies are included in the container.
-
Install Docker CE
- On Windows, only Linux containers are supported at this time. Windows container support is coming very soon! Please follow the document to open Docker Settings and setup a Shared Drive.
- For macOS, please follow the document to choose local directories to share with your containers.
-
Run the IoT Edge Dev Container
Before you run the container, you will need to create a local folder to store your IoT Edge solution files.
Windows
mkdir c:\temp\iotedge docker run -ti -v /var/run/docker.sock:/var/run/docker.sock -v c:/temp/iotedge:/home/iotedge microsoft/iotedgedev
Linux
sudo mkdir /home/iotedge sudo docker run -ti -v /var/run/docker.sock:/var/run/docker.sock -v /home/iotedge:/home/iotedge microsoft/iotedgedev
macOS
mkdir ~/iotedge docker run -ti -v /var/run/docker.sock:/var/run/docker.sock -v ~/iotedge:/home/iotedge microsoft/iotedgedev
-
Initialize IoT Edge solution and setup Azure resources
iotedgedev init
iotedgedev init
will create a solution and setup your Azure IoT Hub in a single command. The solution comes with a default C# module namedfiltermodule
.More information
- You will see structure of current folder like below:
│ .env │ .gitignore │ deployment.template.json │ ├─.vscode │ launch.json │ └─modules └─filtermodule │ .gitignore │ Dockerfile.amd64 │ Dockerfile.amd64.debug │ Dockerfile.arm32v7 │ Dockerfile.windows-amd64 │ filtermodule.csproj │ module.json │ Program.cs
-
Open
.env
file, you will see theIOTHUB_CONNECTION_STRING
andDEVICE_CONNECTION_STRING
environment variables filled correctly. -
Open
deployment.template.json
file- You will see below section in the modules section:
"filtermodule": { "version": "1.0", "type": "docker", "status": "running", "restartPolicy": "always", "settings": { "image": "${MODULES.filtermodule.amd64}", "createOptions": "" } }
- Two default routes are added:
"routes": { "sensorTofiltermodule": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/filtermodule/inputs/input1\")", "filtermoduleToIoTHub": "FROM /messages/modules/filtermodule/outputs/* INTO $upstream" }
-
You will see privacy statement like below:
Welcome to iotedgedev! ------------------------- Telemetry --------- The iotedgedev collects usage data in order to improve your experience. The data is anonymous and does not include commandline argument values. The data is collected by Microsoft. You can change your telemetry settings by updating 'collect_telemetry' to 'no' in ~/.iotedgedev/setting.ini
-
Build IoT Edge module images
sudo iotedgedev build
More information
- You will see a "BUILD COMPLETE" for each module and no error messages in the terminal output.
- Open
config/deployment.json
file, you will see the module image placeholders expanded correctly. - Run
sudo docker image ls
, you will see the module images you just built.
-
Setup and start the IoT Edge Simulator to run the solution
sudo iotedgedev start --setup
IoT Edge Simulator does not support running Python and C modules yet. You'll need IoT Edge Runtime to run your Python and C modules.
More information
- You will see an "IoT Edge Simulator has been started in solution mode." message at the end of the terminal output
- Run
sudo docker ps
, you will see your modules running as well as an edgeHubDev container
-
Monitor messages sent from IoT Edge Simulator to IoT Hub
iotedgedev monitor
More information
- You will see your expected messages sending to IoT Hub
Please refer to the Wiki for details on setup, usage, and troubleshooting.
Please refer to the Contributing file for details on contributing changes.