|
| 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. |
0 commit comments