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.
HUBNAME='YOURHUBNAME'
DEVICEID='DESIREDVMDEVICEID'
PASS='y0urOwnSECureP$ssword'
az iot hub device-identity create --device-id $DEVICEID --edge-enabled --hub-name $HUBNAME
az deployment group create \
--resource-group IoTEdgeResources \
--template-uri "https://aka.ms/iotedge-vm-deploy" \
--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.
https://github.com/microsoft/AzureStorageExplorer/releases/tag/v1.14.2
If you’re using Choco for package management, this command will save you upgrading it in the future
choco pin add -n=microsoftazurestorageexplorer --version 1.14.0