[Update][2017-08-28] The Azure IoT Toolkit extension has been migrated to the official extension.
With the latest release of Azure IoT Toolkit, the code snippet function is added, you could write JavaScript to interact with IoT Hub very conveniently.
Prerequisites:
- VS Code
- Azure IoT Toolkit
- Code Runner (not required but recommended)
- Node.js
Steps:
- Open any folder in VS Code
- In VS Code, open Settings from ‘File’–>’Preferences’. Add device connection string into the Settings:
"azure-iot-toolkit.deviceConnectionString": "HostName=[my-hub].azure-devices.net;DeviceId=[known-device-id];SharedAccessKey=[known-device-key]"
- In terminal, run
npm install azure-iot-device azure-iot-device-mqtt
to install required npm package - Create a empty JavaScript file
- Type
iotS
and select the ‘iotSendD2CMessage’ code snippet - Right click and ‘Run Code’
All are done! You have sent your first ‘Hello World’ message to Azure IoT Hub!