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

[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:

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s