You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This tutorial walks through developing, debugging, and deploying your own code to an Azure IoT Edge device by using IoT Edge for Linux on Windows and Visual Studio 2022. You'll learn the most common developer scenario for IoT Edge solutions by deploying a C# module to a Linux device. You'll deploy and debug a custom IoT Edge module running in a Linux container on Windows. Even if you plan to use a different language or deploy an Azure service, this tutorial is still useful for learning about the development tools and concepts.
19
+
This tutorial walks you through developing, debugging, and deploying your own code to an Azure IoT Edge device by using IoT Edge for Linux on Windows and Visual Studio 2022. You'll learn the most common developer scenario for IoT Edge solutions by deploying a C# module to a Linux device. You'll deploy and debug a custom IoT Edge module running in a Linux container on Windows. Even if you plan to use a different language or deploy an Azure service, this tutorial is still useful for learning about the development tools and concepts.
20
20
21
21
This tutorial includes steps for two IoT Edge development tools:
22
22
@@ -30,7 +30,7 @@ In this tutorial, you learn how to:
30
30
> [!div class="checklist"]
31
31
>
32
32
> * Set up your development machine.
33
-
> * Use the IoT Edge tools for Visual Studio Code to create a new project.
33
+
> * Use IoT Edge development tools to create a new project.
34
34
> * Build your project as a container and store it in an Azure container registry.
35
35
> * Deploy your code to an IoT Edge device.
36
36
@@ -46,7 +46,7 @@ Before you begin:
46
46
* Install or modify Visual Studio 2022 on your development machine. Choose the **Azure development** and **Desktop development with C++** workload options.
47
47
* After your Visual Studio 2022 installation is ready, download and install [Azure IoT Edge Tools](https://marketplace.visualstudio.com/items?itemName=vsc-iot.vs17iotedgetools) from Visual Studio Marketplace.
48
48
49
-
You can use the Azure IoT Edge Tools extension to create and build your IoT Edge solution. The preferred development tool is the Azure IoT Edge Dev Tool CLI. The extension includes the Azure IoT Edge project templates that you use to create the Visual Studio project. Currently, you need the extension installed regardless of the development tool that you use.
49
+
You can use the Azure IoT Edge Tools extension to create and build your IoT Edge solution. The preferred development tool is the Azure IoT Edge Dev Tool CLI. The extension includes the Azure IoT Edge project templates that you use to create the Visual Studio project. Currently, you need to install the extension regardless of the development tool that you use.
50
50
51
51
> [!TIP]
52
52
> If you're using Visual Studio 2019, download and install [Azure IoT Edge Tools for Visual Studio 2019](https://marketplace.visualstudio.com/items?itemName=vsc-iot.vs16iotedgetools) from Visual Studio Marketplace.
@@ -149,7 +149,7 @@ The second step is to configure the IoT Edge for Linux on Windows VM Docker engi
149
149
150
150
### Test the connection
151
151
152
-
The final setup step is to test the Docker connection to the IoT Edge for Linux on Windows VM Docker engine.
152
+
The final setup step is to test the Docker connection to the IoT Edge for Linux on Windows VM Docker engine:
153
153
154
154
1. Get the IP address of the IoT Edge for Linux on Windows VM:
155
155
@@ -218,7 +218,7 @@ The IoT Edge project template in Visual Studio creates a solution that you can d
218
218
>
219
219
> Currently, the Azure IoT Edge Dev Tool CLI doesn't support creating the Visual Studio project type. You need to use the Azure IoT Edge Tools extension to create the Visual Studio project.
220
220
221
-
1. In Visual Studio, create a new project.
221
+
1. In Visual Studio, create a new project by selecting **Create a new project** on the start page or by selecting the **New Project** button on the toolbar.
222
222
223
223
1. On the **Create a new project** page, search for **Azure IoT Edge**. Select the project that matches the platform (Linux IoT Edge module) and architecture for your IoT Edge device, and then select **Next**.
224
224
@@ -243,7 +243,9 @@ Now, you have an IoT Edge project and an IoT Edge module in your Visual Studio s
243
243
244
244
### Project structure
245
245
246
-
Your solution has two project-level folders: a main project folder and a module folder. For example, you might have a main project folder named `AzureIotEdgeApp1` and a module folder named `IotEdgeModule1`. The main project folder contains your deployment manifest.
246
+
Your solution has two project-level folders: a main project folder and a module folder. For example, you might have a main project folder named `AzureIotEdgeApp1` and a module folder named `IotEdgeModule1`.
247
+
248
+
The main project folder contains your [deployment manifest](module-deployment-monitoring.md#deployment-manifest). The deployment manifest is a JSON document that describes the modules to be configured on the targeted IoT Edge device.
247
249
248
250
The module folder contains a file for your module code. It's named either `Program.cs` or `main.c`, depending on the language that you chose. This folder also contains a file named `module.json` that describes the metadata of your module. Various Docker files provide the necessary information to build your module as a Windows or Linux container.
249
251
@@ -267,7 +269,7 @@ Currently, the latest stable runtime version is 1.4. You should update the IoT E
267
269
268
270
:::image type="content" source="./media/how-to-visual-studio-develop-module/set-iot-edge-runtime-version.png" alt-text="Screenshot of selections for setting an IoT Edge runtime version.":::
269
271
270
-
1. Use the drop-down menu to choose the runtime version that your IoT Edge devices are running. Then select **OK** to save your changes. If you didn't make any changes, select **Cancel**.
272
+
1. Use the dropdown menu to choose the runtime version that your IoT Edge devices are running. Then select **OK** to save your changes. If you didn't make any changes, select **Cancel**.
271
273
272
274
Currently, the extension doesn't include a selection for the latest runtime versions. If you want to set the runtime version higher than 1.2, open the `deployment.debug.template.json` deployment manifest file. Change the runtime version for the system runtime module images `edgeAgent` and `edgeHub`. For example, if you want to use the IoT Edge runtime version 1.4, change the following lines in the deployment manifest file:
273
275
@@ -289,7 +291,7 @@ Currently, the latest stable runtime version is 1.4. You should update the IoT E
289
291
290
292
::: zone pivot="iotedge-dev-cli"
291
293
292
-
1. Open the `deployment.debug.template.json` deployment manifest file. The [deployment manifest](module-deployment-monitoring.md#deployment-manifest) is a JSON document that describes the modules to be configured on the targeted IoT Edge device.
294
+
1. Open the `deployment.debug.template.json` deployment manifest file.
293
295
1. Change the runtime version for the system runtime module images `edgeAgent` and `edgeHub`. For example, if you want to use IoT Edge runtime version 1.4, change the following lines in the deployment manifest file:
294
296
295
297
```json
@@ -310,7 +312,7 @@ Currently, the latest stable runtime version is 1.4. You should update the IoT E
310
312
311
313
### Set up the Visual Studio 2022 remote Docker engine instance
312
314
313
-
Configure the Azure IoT Edge Tools extension to use the remote Docker engine that runs inside the IoT Edge for Linux on Windows virtual machine:
315
+
Configure the Azure IoT Edge Tools extension to use the remote Docker engine that runs inside the IoT Edge for Linux on Windows VM:
@@ -332,13 +334,13 @@ When you're ready to customize the module template with your own code, use the [
332
334
333
335
## Build and push a single module
334
336
335
-
Typically, you want to test and debug each module before running it within an entire solution with multiple modules. Because the solution will build or debug by using the Docker engine running inside the IoT Edge for Linux on Windows VM, the first step is building and publishing the module to enable remote debugging.
337
+
Typically, you want to test and debug each module before running it within an entire solution with multiple modules. Because the solution will build or debug by using the Docker engine running inside the IoT Edge for Linux on Windows VM, the first step is building and publishing the module to enable remote debugging:
336
338
337
339
1. In **Solution Explorer**, select the module project folder (for example, `myIotEdgeModule`).
338
340
339
341
1. Set the custom module as the startup project. On the menu, select **Project** > **Set as StartUp Project**.
340
342
341
-
1. To debug the C# Linux module, you need to update `Dockerfile.amd64.debug` file to enable the SSH service. Update the `Dockerfile.amd64.debug` file to use the following template: [Dockerfile for Azure IoT Edge AMD64 C# Module with Remote Debug Support](https://raw.githubusercontent.com/Azure/iotedge-eflow/main/debugging/Dockerfile.amd64.debug).
343
+
1. To debug the C# Linux module, you need to update the `Dockerfile.amd64.debug` file to enable the SSH service. Update the `Dockerfile.amd64.debug` file to use the following template: [Dockerfile for Azure IoT Edge AMD64 C# Module with Remote Debug Support](https://raw.githubusercontent.com/Azure/iotedge-eflow/main/debugging/Dockerfile.amd64.debug).
342
344
343
345
> [!NOTE]
344
346
> When you select **Debug**, Visual Studio uses `Dockerfile.(amd64|windows-amd64).debug` to build Docker images. This file includes the .NET Core command-line debugger VSDBG in your container image while building it. For production-ready IoT Edge modules, we recommend that you use the **Release** configuration, which uses `Dockerfile.(amd64|windows-amd64)` without VSDBG.
In Visual Studio, open the `deployment.debug.template.json` deployment manifest file in the main project. The [deployment manifest](module-deployment-monitoring.md#deployment-manifest) is a JSON document that describes the modules to be configured on the targeted IoT Edge device.
458
+
In Visual Studio, open the `deployment.debug.template.json` deployment manifest file in the main project.
457
459
458
460
Before deployment, you need to update your Azure Container Registry credentials, your module images, and the proper `createOptions` values. For more information about `createOption` values, see [How to configure container create options for IoT Edge modules](how-to-use-create-options.md).
459
461
@@ -516,7 +518,7 @@ Before deployment, you need to update your Azure Container Registry credentials,
516
518
517
519
1. In an elevated PowerShell session, run the following commands:
518
520
519
-
1. Get the `moduleId` value, based on the name for the Linux C# module. Replace the `<iot-edge-module-name` placeholder with your module's name.
521
+
1. Get the `moduleId` value, based on the name for the Linux C# module. Replace the `<iot-edge-module-name>` placeholder with your module's name.
0 commit comments