Send your first 'Hello World' message to Azure IoT Hub using JavaScript with Azure IoT Toolkit for VS Code


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:

Steps:

  1. Open any folder in VS Code
  2. 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]"
  3. In terminal, run npm install azure-iot-device azure-iot-device-mqtt to install required npm package
  4. Create a empty JavaScript file
  5. Type iotS and select the 'iotSendD2CMessage' code snippet
  6. Right click and 'Run Code'

All are done! You have sent your first 'Hello World' message to Azure IoT Hub!

snippet

Comments (0)

Skip to main content