IOT Edge Cheat Sheet

IOT Edge Cheat Sheet

2020, Dec 06    

Deploying a Linux VM as an Edge Device

I’ve needed to deploy quite a few Linux VM’s, here’s the script that i run from WSL. It uses the AZ CLI and deploys to an existing resource group.


az iot hub device-identity create --device-id $DEVICEID --edge-enabled --hub-name $HUBNAME

az deployment group create \
--resource-group IoTEdgeResources \
--template-uri "" \
--parameters dnsLabelPrefix=${DEVICEID,,} \
--parameters adminUsername='azureUser' \
--parameters deviceConnectionString=$(az iot hub device-identity connection-string show --device-id $DEVICEID --hub-name $HUBNAME -o tsv) \
--parameters authenticationType='password' \
--parameters adminPasswordOrKey="$PASS"

az vm list -g IOTEDGERESOURCES -d | grep ${DEVICEID,,}

IOT Edge Commands

Here’s the commands i run most frequently.

Command Purpose
iotedge list Lists all installed modules
iotedge logs modulename Shows the logs for a specific running module
iotedge logs edgeAgent Shows the agent logs, helpful for when your module won’t create
iotedge check –verbose Performs basic agent health checks, good for when your module deployment fails on the edge as the first place to troubleshoot
iotedge support-bundle –since 24h Grabs the logs, and collates in one tidy zip for downloading and further inspection

AZ Edge Commands

Command Purpose
az iot hub generate-sas-token -n iothubName Generates a token that lasts an hour

AZ Edge Storage

A really popular workload to run on the edge is Azure Blob Storage. However (at time of writing) the latest build of the tool doesn’t work with the Edge image. You’ll need to use an older version.