2016-10-28 15:17:00 +03:00
# Azure IoT Toolkit
2016-10-28 08:46:08 +03:00
2017-08-18 05:49:53 +03:00
[![Join the chat at https://gitter.im/Microsoft/azure-iot-toolkit ](https://badges.gitter.im/Microsoft/azure-iot-toolkit.svg )](https://gitter.im/Microsoft/azure-iot-toolkit?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge)
2017-11-13 09:49:03 +03:00
Interact with Azure IoT Hub, IoT Device Management, IoT Edge Management, IoT Hub Code Snippets.
2016-10-28 08:46:08 +03:00
2017-06-05 11:10:36 +03:00
## 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
2017-06-15 09:16:55 +03:00
* Send C2D message to device
* Monitor C2D message from IoT Hub
2017-08-02 11:43:25 +03:00
* Invoke Direct Method
* Get/update Device Twin
2017-11-15 06:18:59 +03:00
* Interact with Azure IoT Edge < sup > Preview</ sup > (Install [Azure IoT Edge ](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge ) for more IoT Edge support)
2017-11-13 09:49:03 +03:00
* Manage Edge runtime
* Create deployment for Edge device
2017-12-19 11:21:33 +03:00
* Generate Edge setup configuration file
* Generate Edge deployment manifest
2017-06-05 11:10:36 +03:00
### Prerequisites
1. In Explorer of VS Code, click "IoT Hub Devices" in the bottom left corner.
2017-08-25 09:07:24 +03:00
![Click Device Explorer ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/device-explorer-click.png )
2017-06-05 11:10:36 +03:00
2017-09-12 09:29:21 +03:00
2. Click "Set IoT Hub Connection String" in context menu.
![Set Connection String ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/set-connection-string.png )
2017-11-14 06:16:37 +03:00
3. 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 format is `HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>` ).
2017-06-05 11:10:36 +03:00
2017-08-25 09:07:24 +03:00
![Enter Connection String ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/enter-connection-string.png )
2017-06-05 11:10:36 +03:00
2017-09-12 09:29:21 +03:00
4. The device list will be shown.
2017-06-05 11:10:36 +03:00
2017-08-25 09:07:24 +03:00
![Device Explorer ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/device-explorer.png )
2016-10-28 08:46:08 +03:00
2017-09-12 09:29:21 +03:00
**NOTE**: You could also 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.
2017-08-17 06:51:44 +03:00
2017-09-29 11:24:21 +03:00
### Sign in to Azure
Instead of copying and pasting to set IoT Hub Connection String, you could sign in to Azure to select IoT Hub from your Azure Subscription.
1. Click "Select IoT Hub" in context menu.
![Select IoT Hub ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/select-iot-hub.png )
2017-10-17 06:37:10 +03:00
2. If you have not signed in to Azure, a pop-up will show to let you sign in to Azure.
3. After you sign in, your Azure Subscription list will be shown, then select an Azure Subscription.
2017-09-29 11:24:21 +03:00
4. Your IoT Hub list will be shown, then select an IoT Hub.
5. The device list will be shown.
2017-08-16 14:31:44 +03:00
## Code Snippets
2017-03-06 10:10:54 +03:00
2017-03-06 10:30:59 +03:00
| Trigger | Content |
| ---- | ---- |
| iotSendD2CMessage | Send D2C message to IoT Hub |
| iotMonitorD2CMessage | Monitor D2C message for IoT Hub |
2017-03-08 05:44:21 +03:00
| iotSendC2DMessage | Send C2D message to device |
| iotMonitorC2DMessage | Monitor C2D message from IoT Hub |
2017-06-05 11:10:36 +03:00
| iotCallDirectMethods | Send direct methods to device |
| iotReceiveDirectMethods | Receive direct methods from IoT Hub |
2017-03-06 10:10:54 +03:00
2017-08-21 07:58:53 +03:00
![Snippet ](https://github.com/formulahendry/vscode-azure-iot-toolkit/raw/master/images/snippet.gif )
2017-03-06 10:30:59 +03:00
> After code snippet is created, you need to install corresponding npm package (e.g. [azure-iot-device-mqtt](https://www.npmjs.com/package/azure-iot-device-mqtt)) to run the code snippet.
> If you want to 'Run Code' directly, you need to install [Code Runner](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner).
2017-03-06 10:10:54 +03:00
2016-10-28 15:06:48 +03:00
## Configuration
2016-10-28 08:46:08 +03:00
2017-08-16 14:31:44 +03:00
IoT Hub Connection String:
2016-10-28 15:06:48 +03:00
```json
{
2017-08-16 14:31:44 +03:00
"azure-iot-toolkit.iotHubConnectionString": "HostName=< my-hub > .azure-devices.net;SharedAccessKeyName=< my-policy > ;SharedAccessKey=< my-policy-key > "
2016-10-28 15:06:48 +03:00
}
```
2016-10-28 08:46:08 +03:00
2017-08-16 14:31:44 +03:00
Device Connection String:
2016-10-28 15:06:48 +03:00
```json
{
2017-08-16 14:31:44 +03:00
"azure-iot-toolkit.deviceConnectionString": "HostName=< my-hub > .azure-devices.net;DeviceId=< known-device-id > ;SharedAccessKey=< known-device-key > "
2016-10-28 15:06:48 +03:00
}
```
2016-10-28 08:46:08 +03:00
2017-08-17 06:51:44 +03:00
IoT Hub Consumer Group (default is `"$Default"` ):
2016-10-28 15:06:48 +03:00
```json
{
2017-02-27 16:23:08 +03:00
"azure-iot-toolkit.iotHubConsumerGroup": "$Default"
}
```
2017-08-16 14:31:44 +03:00
Whether to show verbose info when monitoring messages (default is `false` ):
2017-02-28 10:34:34 +03:00
```json
{
2017-08-16 14:31:44 +03:00
"azure-iot-toolkit.showVerboseMessage": false
2017-02-28 10:34:34 +03:00
}
```
2017-08-16 14:31:44 +03:00
Whether to stringify device-to-cloud messages (default is `false` ):
2017-06-28 04:21:03 +03:00
```json
{
2017-08-16 14:31:44 +03:00
"azure-iot-toolkit.iotHubD2CMessageStringify": false
2016-10-28 15:06:48 +03:00
}
```
2017-09-22 07:03:21 +03:00
Whether to show Connection String Input Box on startup (default is `true` ):
```json
{
"azure-iot-toolkit.showConnectionStringInputBox": true
}
```
Whether to show IoT Hub info when IoT Hub Connection String is not set (default is `true` ):
```json
{
"azure-iot-toolkit.showIoTHubInfo": true
}
```