One of the key capabilities of Azure IoT Edge is being able to deploy modules to your IoT Edge devices from the cloud. An IoT Edge module is an executable package implemented as a container. In this section, you deploy a module that generates telemetry for your simulated device.
In the Azure portal
-
Navigate to your IoT hub.
-
Go to IoT Edge under Automatic Device Management and select your IoT Edge device.
-
Select Set Modules.
A three-step wizard opens in the portal, which guides you through
* adding modules,
* specifying routes, and
* reviewing the deployment.
Under Explorer select IoT Edge and select Edge Device
Click on Set Modules
In the Add Modules step of the wizard, find the Deployment Modules section. Click Add then select IoT Edge Module.
Use the Temperature Sensor Simulator pre-built module.
In the Name field, enter tempsensor.
In the Image URI field, enter mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0.
Leave the other settings unchanged, and select Save.
Note: Module will send 500 messages, you will have to restart the module to resend the messages. You can add an envirnment variable MessageCount to the number of messages that should be sent (set it to -1 to send unlimited messages)
In the Specify Routes step of the wizard, you should have a default route that sends all messages from all modules to IoT Hub. If not, add the following code then Click Next
{
"routes": {
"route": "FROM /messages/* INTO $upstream"
}
}
In the Review Deployment step of the wizard, select Submit.
Click Submit
Return to the device details page and select Refresh.
In addition to the edgeAgent module that was created when you first started the service, you should see another runtime module called edgeHub and the tempSensor module listed.
It may take a few minutes for the new modules to show up. The IoT Edge device has to retrieve its new deployment information from the cloud, start the containers, and then report its new status back to IoT Hub.
SSH into Linux VM and list the modules. You will see the 3 modules deployed on to the edge device. Use command
iotedge list
Look at tempSensor module logs, you will see telemetry being sent to the cloud
iotedge logs tempsensor
Note: tempsensor module will stop sending messages after 500 messages have been sent. You can restart it using the following command:
```shell
iotedge restart tempsensor
```