Skip to content

Commit 05308de

Browse files
authored
Merge pull request #203829 from PatAltimore/patricka-dev-cli
Add CLI to vs code dev how-to
2 parents 382e75b + 9598004 commit 05308de

File tree

6 files changed

+633
-180
lines changed

6 files changed

+633
-180
lines changed

articles/iot-edge/how-to-vs-code-develop-module.md

Lines changed: 557 additions & 180 deletions
Large diffs are not rendered by default.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
ms.topic: include
3+
ms.date: 07/07/2022
4+
author: PatAltimore
5+
ms.author: patricka
6+
ms.service: iot-edge
7+
services: iot-edge
8+
---
9+
10+
1. Select **Start Debugging** or press **F5** to start the debug session.
11+
12+
1. In the Visual Studio Code integrated terminal, run the following command to send a **Hello World** message to your module. This is the command shown in previous steps when you set up IoT Edge simulator.
13+
14+
```bash
15+
curl --header "Content-Type: application/json" --request POST --data '{"inputName": "input1","data":"hello world"}' http://localhost:53000/api/v1/messages
16+
```
17+
18+
> [!NOTE]
19+
> If you are using Windows, making sure the shell of your Visual Studio Code integrated terminal is **Git Bash** or **WSL Bash**. You cannot run the `curl` command from a PowerShell or command prompt.
20+
> [!TIP]
21+
> You can also use [PostMan](https://www.getpostman.com/) or other API tools to send messages through instead of `curl`.
22+
23+
1. In the Visual Studio Code Debug view, you'll see the variables in the left panel.
24+
25+
1. To stop your debugging session, select the Stop button or press **Shift + F5**, and then run **Azure IoT Edge: Stop IoT Edge Simulator** in the command palette to stop the simulator and clean up.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
ms.topic: include
3+
ms.date: 07/08/2022
4+
author: PatAltimore
5+
ms.author: patricka
6+
ms.service: iot-edge
7+
services: iot-edge
8+
---
9+
10+
Your module requires use of a **ModuleClient** object in the default module code so that it can start, run, and route messages. You'll also use the default input channel **input1** to take action when the module receives messages.
11+
12+
### Set up IoT Edge simulator
13+
14+
IoT Edge modules need an IoT Edge environment to run and debug. You can use an IoT Edge simulator on your development machine instead of running the full IoT Edge security subsystem and runtime. You can either simulate a device to debug solutions with multiple modules, or simulate a single module application.
15+
16+
#### Option 1: Simulate an IoT Edge solution:
17+
18+
1. In the **Explorer** tab on the left side, expand the **Azure IoT Hub** section. Right-click on your IoT Edge device ID, and then select **Setup IoT Edge Simulator** to start the simulator with the device connection string.
19+
1. You can see the IoT Edge Simulator has been successfully set up by reading the progress detail in the integrated terminal.
20+
21+
#### Option 2: Simulate a single IoT Edge module:
22+
23+
1. In the Visual Studio Code command palette, run the command **Azure IoT Edge: Start IoT Edge Hub Simulator for Single Module**.
24+
1. Provide the names of any inputs that you want to test with your module. If you're using the default sample code, use the value **input1**.
25+
1. The command triggers the **iotedgehubdev** CLI and then starts the IoT Edge simulator and a testing utility module container. You can see the output similar to the following in the integrated terminal if the simulator has been started in single module mode successfully. The output includes an example `curl` command to send a message to the simulator. You'll use the `curl` command later.
26+
27+
```output
28+
D:\Workspaces\EdgeSolution>iotedgehubdev start -i "input1"
29+
...
30+
```
31+
32+
You can use the Docker Explorer view in Visual Studio Code to see the module's running status.
33+
34+
:::image type="content" source="media/simulator-status.png" alt-text="Screenshot showing simulator module status in the Docker Explorer pane of VS Code.":::
35+
36+
The **edgeHubDev** container is the core of the local IoT Edge simulator. It can run on your development machine without the IoT Edge security daemon and provides environment settings for your native module app or module containers. The **input** container exposes REST APIs to help bridge messages to the target input channel on your module.
37+
38+
### Debug module in launch mode
39+
40+
After the simulator has been started successfully, you can debug your module code.
41+
42+
Prepare your environment for debugging, set a breakpoint in your module, and select the debug configuration to use.

articles/zone-pivot-groups.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,15 @@ groups:
14141414
title: Alerts
14151415
- id: workbooks
14161416
title: Workbooks
1417+
# Owner: patricka
1418+
- id: iotedge-dev
1419+
title: IoT Edge development tool
1420+
prompt: Choose an Azure IoT Edge development tool
1421+
pivots:
1422+
- id: iotedge-dev-cli
1423+
title: Command line interface
1424+
- id: iotedge-dev-vscode
1425+
title: Azure IoT Edge VS Code extension
14171426
# Owner: barclayn
14181427
- id: identity-mi-methods
14191428
title: Managed identities methods

0 commit comments

Comments
 (0)