3.3 KiB
3.3 KiB
Azure IoT Toolkit
Interact with Azure IoT Hub, IoT Device Management, IoT Hub Code Snippets.
Device Explorer
- Device management
- List devices
- Get device info
- Create device
- Delete device
- Interact with Azure IoT Hub
- Send D2C message to IoT Hub
- Monitor IoT Hub D2C message
- Send C2D message to device
- Monitor C2D message from IoT Hub
- Invoke Direct Method
- Get/update Device Twin
Prerequisites
- In Explorer of VS Code, click "IoT Hub Devices" in the bottom left corner.
- If you have not set Iot Hub Connection String before, an input box will pop up, then enter your Iot Hub Connection String (It is one-time configuration, and please make sure it is Iot Hub Connection String not Device Connection String).
- The device list will be shown.
NOTE: You could go to File > Preferences > Settings (Code > Preferences > Settings on Mac), update the config of azure-iot-toolkit.iotHubConnectionString
to change your IoT Hub Connection String.
Code Snippets
Trigger | Content |
---|---|
iotSendD2CMessage | Send D2C message to IoT Hub |
iotMonitorD2CMessage | Monitor D2C message for IoT Hub |
iotSendC2DMessage | Send C2D message to device |
iotMonitorC2DMessage | Monitor C2D message from IoT Hub |
iotCallDirectMethods | Send direct methods to device |
iotReceiveDirectMethods | Receive direct methods from IoT Hub |
After code snippet is created, you need to install corresponding npm package (e.g. azure-iot-device-mqtt) to run the code snippet. If you want to 'Run Code' directly, you need to install Code Runner.
Configuration
IoT Hub Connection String:
{
"azure-iot-toolkit.iotHubConnectionString": "HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>"
}
Device Connection String:
{
"azure-iot-toolkit.deviceConnectionString": "HostName=<my-hub>.azure-devices.net;DeviceId=<known-device-id>;SharedAccessKey=<known-device-key>"
}
IoT Hub Consumer Group (default is "$Default"
):
{
"azure-iot-toolkit.iotHubConsumerGroup": "$Default"
}
Whether to show verbose info when monitoring messages (default is false
):
{
"azure-iot-toolkit.showVerboseMessage": false
}
Whether to stringify device-to-cloud messages (default is false
):
{
"azure-iot-toolkit.iotHubD2CMessageStringify": false
}