Deploying Windows IoT Edge Modules
This guide walks you through the process of deploying modules to a Windows IoT Edge device, from prerequisites to troubleshooting common issues.
Overview+
Windows IoT Edge extends Azure IoT capabilities to on‑premises devices, allowing you to run cloud‑based workloads locally.
- Device provisioning
- Edge runtime installation
- Module deployment via
deployment.json
Prerequisites+
- Windows 10 IoT Enterprise / IoT Core (1809 or later)
- Azure subscription with IoT Hub created
- Device with internet connectivity
Install the following tools on your development PC:
choco install azure-cli choco install iotedge
Step‑by‑Step Deployment+
1. Register the device in IoT Hub
az iot hub device-identity create \
--hub-name MyIoTHub \
--device-id myEdgeDevice \
--edge-enabled
2. Install IoT Edge runtime on the device
powershell -Command "Invoke-WebRequest -Uri https://aka.ms/iotedge-windows -OutFile iotedge.msi" msiexec /i iotedge.msi /quiet
3. Configure connection string
iotedge config mp --connection-string "HostName=MyIoTHub.azure-devices.net;DeviceId=myEdgeDevice;SharedAccessKey=XXXX"
4. Create deployment.json
{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"modules": {
"sampleModule": {
"settings": {
"image": "mcr.microsoft.com/azureiotedge-sample:latest",
"createOptions": "{}"
},
"type": "docker",
"status": "running",
"restartPolicy": "always"
}
}
}
},
"$edgeHub": {
"properties.desired": {
"routes": {
"route": "FROM /messages/* INTO $upstream"
}
}
}
}
}
5. Deploy the manifest
az iot edge set-modules --device-id myEdgeDevice --hub-name MyIoTHub --content ./deployment.json
After a few seconds the module will appear in iotedge list.
Troubleshooting+
Common Issues
- Module fails to start: Check Docker logs with
docker logs <module_name>. - Device not connecting: Verify the connection string and firewall settings.
- Edge runtime not running: Restart service:
net stop iotedge && net start iotedge.
Helpful Commands
iotedge check iotedge logs <module_name> az iot hub monitor-feedback --hub-name MyIoTHub --device-id myEdgeDevice