Skip to content

Latest commit

 

History

History
110 lines (60 loc) · 5.6 KB

deploy-marketplace-modules.md

File metadata and controls

110 lines (60 loc) · 5.6 KB

Deploy marketplace modules

https://unsplash.com/photos/OiOLKlYGv94

The easiest way to start using IoT edge is to deploy ready-made modules on the device. It's very similar to how developer use software packages developed by other developers to speed up development. Azure Marketplace has multiple modules for both learning and production usage.

There is one famous module that acts as the hello world module for IoT edge and its called Simulated Temperature Sensor module. This module simply simulates some temperature readings that increase overtime till a certain threshold. It's a good starting point for playing with IoT edge as we don't need to worry about using a physical device/sensor setup. The module source code is also available on GitHub part of IoT edge source code repo itself.

To deploy this module on our device, it can be done using 2 methods. The first one is to do it from marketplace directly and follow some wizard to select the device to deploy the module to. The second method is via IoT edge device list in Azure portal. We will use the second method here.

  • Open IoT edge device list page in Azure portal
  • Click on edge-device device name in the list

  • Click Set Modules in device page

  • In the IoT Edge Modules section, click Add > Marketplace Module

  • Select Simulated Temperature Sensor module and then click the Next: Routes > button to move on to next page ****

  • You see the below routes pre-populated, remove first route.

  • Make sure the routes looks like below which means all messages generated by temperature sensor module are pushed to IoT hub in the cloud ($upstream bit)

  • Click Next: Review + create > button
  • Next page shows JSON representation of the configuration we want to deploy to the device

  • Near the end of the configuration, there is the configuration settings for the temperature sensor module. Every module can define some knobs to tweak its own functionality
"SimulatedTemperatureSensor": {
            "properties.desired": {
                "SendData": true,
                "SendInterval": 5
            }
        }
  • Click Create and wait a few seconds for the IoT hub to sync this configuration to the device and for the device to pull docker image of the module and run it.

To confirm the module is up and running on the device now, run:

sudo iotedge list

Sweet, the temperature sensor module is up and running and also edgeHub module appeared as well.

The device now shows OK status in portal and shows 3 modules running.

Open device details page for a detailed view of modules running on the device.

Let's use VS Code to inspect messages sent from the edge device to IoT hub.

If everything works fine, the output would be similar to this.

All modules whether they are system or custom modules can be inspected for their internal logs as well.

sudo iotedge logs --tail 10 SimulatedTemperatureSensor

{% hint style="info" %} Pro Tip: Sometimes it would be very important to inspect and check logs of system modules (edgeAgent & edgeHub).

Two important topics to consider are:

  • Connectivity: Because our edge device is hosted in Azure, firewall rules might enable access to Azure services without further actions needed. IoT edge connects to IoT hub using some default settings and port numbers so if you have your device in a more restricted network, just review what ports are open on the device and network firewall as well. The following articles have more details on production preparation and network settings.
  • Docker registry access: If one of the modules has its docker image hosted on a private repository, then credentials have to be provided in deployment configuration. So if the credentials are wrong or missing, an error will be shown in edgeAgent logs about not being able to pull the module image.

The below screenshot shows edgeAgent connecting to IoT Hub using AMQP. You can monitor edgeAgent or edgeHub using commands like:

sudo iotedge logs edgeAgent {% endhint %}

Phew, that was quite an achievement. It's still considered a hello world application but good to have all those moving parts working in harmony. You can no log out from that VM to be ready for the next exercise.

The next task is to develop your own custom module and have it also interact with temperature sensor module. Most business problems usually require custom logic and this is our chance to apply our development skills to solve those problems.