Proof of Concept - how to use custom debian/ubuntu packages with Azure IOT Device Update
wget https://packages.microsoft.com/config/ubuntu/18.04/multiarch/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.deb
sudo apt-get update; \ sudo apt-get install moby-engine
sudo nano /etc/docker/daemon.json
Replace the content with:
{ "registry-mirrors": ["http://localhost:5000"] }
sudo systemctl restart docker
sudo apt-get update; \ sudo apt-get install aziot-edge
sudo iotedge config mp --connection-string 'PASTE_DEVICE_CONNECTION_STRING_HERE'
sudo iotedge config apply
sudo cat /etc/aziot/config.tomlDeploy Azure IOT Edge Modules
Follow this steps
To deploy your IoT Edge modules, go to your IoT hub in the Azure portal, then:
- Select Devices from the IoT Hub menu.
- Select your device to open its page.
- Select the Set Modules tab.
- Since we want to deploy the IoT Edge default modules (edgeAgent and edgeHub), we don't need to add any modules to this pane, so select Review + create at the bottom.
- You see the JSON confirmation of your modules. Select Create to deploy the modules.
It will generate a deployment manifest similar to this one:
{ "modulesContent": { "$edgeAgent": { "properties.desired": { "schemaVersion": "1.1", "runtime": { "type": "docker", "settings": {} }, "systemModules": { "edgeAgent": { "settings": { "image": "mcr.microsoft.com/azureiotedge-agent:1.4" }, "type": "docker" }, "edgeHub": { "restartPolicy": "always", "settings": { "image": "mcr.microsoft.com/azureiotedge-hub:1.4", "createOptions": "{\"HostConfig\":{\"PortBindings\":{\"443/tcp\":[{\"HostPort\":\"443\"}],\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}]}}}" }, "status": "running", "type": "docker" } }, "modules": {} } }, "$edgeHub": { "properties.desired": { "schemaVersion": "1.1", "storeAndForwardConfiguration": { "timeToLiveSecs": 7200 }, "routes": {} } } } }
Note: It might take a few seconds (up to 2 mins) for the portal to reflect the deployments status correctly. Sometimes one of the modules seems to be in status error.
Verify Modules deploymentIOT Edge Runtime
sudo iotedge system status
Docker containers
Install device update agent on Ubuntusudo apt-get install deviceupdate-agent
sudo nano /etc/adu/du-config.json
Replace the content with:
{ "schemaVersion": "1.1", "aduShellTrustedUsers": [ "adu", "do" ], "iotHubProtocol": "mqtt", "manufacturer": "Contoso", "model": "Video", "agents": [ { "name": "corretto-machine-edge-01", "runas": "adu", "connectionSource": { "connectionType": "string", "connectionData": "PASTE_DEVICE_CONNECTION_STRING_HERE" }, "manufacturer": "Contoso", "model": "Video" } ] }
sudo systemctl restart deviceupdate-agent
sudo systemctl status deviceupdate-agent
Follow this steps
- Sign in to the Azure portal and go to the IoT hub.
- On the left pane, under Devices, find your IoT Edge device and go to the Device twin or module twin.
- In the module twin of the Device Update agent module, delete any existing Device Update tag values by setting them to null. If you're using Device identity with Device Update agent, make these changes on the device twin.
- Add a new Device Update tag value.
In our case the tag is:
"tags": { "ADUGroup": "test-corretto" },Add Custom Package Debian Repository Origin
wget -qO - https://raw.githubusercontent.com/UlisesGascon/poc-custom-package-debian-repository/main/PUBLIC.KEY | sudo apt-key add -
echo "deb https://raw.githubusercontent.com/UlisesGascon/poc-custom-package-debian-repository/main/ bionic main" | sudo tee /etc/apt/sources.list.d/ulisesgascon.list
Note: this step can be automated using ADU
Import and deploy the updateImport the update Following this steps, but use the files downloaded in the previous step and not the ones mentioned in the example.
Check that the group test-corretto
is listed, and that the update is available. Following this steps
Deploy the update Following this steps
demoapi
is running.systemctl -l status demoapi.service
demoapi
services is responsive.curl http://localhost:5000/WeatherForecast
The expected response is similar to:
[{"date":"2023-08-04","temperatureC":4,"temperatureF":39,"summary":"Warm"},{"date":"2023-08-05","temperatureC":-14,"temperatureF":7,"summary":"Scorching"},{"date":"2023-08-06","temperatureC":-14,"temperatureF":7,"summary":"Warm"},{"date":"2023-08-07","temperatureC":-4,"temperatureF":25,"summary":"Chilly"},{"date":"2023-08-08","temperatureC":7,"temperatureF":44,"summary":"Cool"}]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4