vscode-azure-iot-toolkit/README.md

133 строки
5.1 KiB
Markdown
Исходник Обычный вид История

2016-10-28 15:17:00 +03:00
# Azure IoT Toolkit
2016-10-28 08:46:08 +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)
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
* IoT Hub management
* Create IoT Hub
* Select IoT Hub
* Copy IoT Hub Connection String
2017-06-05 11:10:36 +03:00
* Device management
* List devices
* Get device info
* Create IoT device
* Create Edge device
2017-06-05 11:10:36 +03:00
* Delete device
* Copy Device Connection String
2017-06-05 11:10:36 +03:00
* 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
2017-08-02 11:43:25 +03:00
* Invoke Direct Method
* Edit Device Twin
* 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)
* List Edge Moudles
* Edit Module Twin
* Create deployment for Edge device
2017-06-05 11:10:36 +03:00
### Prerequisites
1. In Explorer of VS Code, click "Azure IoT Hub Devices" in the bottom left corner.
2017-06-05 11:10:36 +03:00
2018-03-22 16:04:28 +03:00
![Click Device Explorer](images/device-explorer-click.png)
2017-06-05 11:10:36 +03:00
2. Click "Set IoT Hub Connection String" in context menu.
2018-03-22 16:04:28 +03:00
![Set Connection String](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
2018-03-22 16:04:28 +03:00
![Enter Connection String](images/enter-connection-string.png)
2017-06-05 11:10:36 +03:00
4. The device list will be shown.
2017-06-05 11:10:36 +03:00
2018-03-22 16:04:28 +03:00
![Device Explorer](images/device-explorer.png)
2016-10-28 08:46:08 +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
### 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.
2018-03-22 16:04:28 +03:00
![Select IoT Hub](images/select-iot-hub.png)
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.
4. Your IoT Hub list will be shown, then select an IoT Hub.
5. The device list will be shown.
## Code Snippets
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 |
2018-03-22 16:04:28 +03:00
![Snippet](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).
2016-10-28 15:06:48 +03:00
## Configuration
2016-10-28 08:46:08 +03:00
IoT Hub Connection String:
2016-10-28 15:06:48 +03:00
```json
{
"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
Device Connection String:
2016-10-28 15:06:48 +03:00
```json
{
"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"
}
```
Whether to show verbose info when monitoring messages (default is `false`):
```json
{
"azure-iot-toolkit.showVerboseMessage": false
}
```
Whether to stringify device-to-cloud messages (default is `false`):
```json
{
"azure-iot-toolkit.iotHubD2CMessageStringify": false
2016-10-28 15:06:48 +03:00
}
```
Whether to show IoT Hub info when IoT Hub Connection String is not set (default is `true`):
```json
{
"azure-iot-toolkit.showIoTHubInfo": true
}
```
2017-12-22 06:57:27 +03:00
2018-06-15 09:16:22 +03:00
## Resources
- [Channel 9 video: Walkthrough of Azure IoT Toolkit extension](https://channel9.msdn.com/Shows/Internet-of-Things-Show/Azure-IoT-Toolkit-extension-for-Visual-Studio-Code)
- [Handy Tool When You Develop With Azure IoT](https://blogs.msdn.microsoft.com/iotdev/2017/09/01/handy-tool-when-you-develop-with-azure-iot/)
2017-12-22 06:57:27 +03:00
## Data/Telemetry
This project collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](http://go.microsoft.com/fwlink/?LinkId=521839) to learn more.
If you dont wish to send usage data to Microsoft, you can set the `telemetry.enableTelemetry` setting to `false`. Learn more in our [FAQ](https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting).