The purpose of this repository is a Simple Example of sending a Direct Method Message to a Device.
PreRequisites
Requires the use of direnv.
Requires the use of Azure CLI.
- iot-resources - Deploying IoT Resources and x509 Management
- iot-device-edge - Simple Edge Testing
- iot-device-js - Simple Device Testing
- iot-control-js - Simple Control Testing
The device only requires one environment variable to be set.
- HUB_CONNECTION_STRING: Connection String of the Hub
# Setup the Environment Variables
export GROUP="iot-resources"
export HUB=$(az iot hub list --resource-group $GROUP --query [].name -otsv)
export HUB_CONNECTION_STRING="$(az iot hub show-connection-string --hub-name $HUB -otsv)"
DEVICE="device" MESSAGE_INTERVAL="3" ./setInterval.js
Using the Azure Portal you can send a direct method to the device that performs the same action as this code.
-
Select the Desired Device and open the DirectMethod Blade
-
Method Name:
setInterval
Payload:5