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
Copy file name to clipboardExpand all lines: articles/iot-edge/how-to-vs-code-develop-module.md
+30-28Lines changed: 30 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,15 +72,15 @@ To build and deploy your module image, you need Docker to build the module image
72
72
73
73
::: zone pivot="iotedge-dev-cli"
74
74
75
-
- Install the Python-based [Azure IoT Edge Dev Tool](https://pypi.org/project/iotedgedev/) with the following command in your terminal to set up your local development environment to debug, run, and test your IoT Edge solution. [Python (3.6/3.7)](https://www.python.org/downloads/) and [Pip3](https://pip.pypa.io/en/stable/installation/) are required.
75
+
- Install the Python-based [Azure IoT Edge Dev Tool](https://pypi.org/project/iotedgedev/) with the following command to enable you to debug, run, and test your IoT Edge solution. [Python (3.6/3.7)](https://www.python.org/downloads/) and [Pip3](https://pip.pypa.io/en/stable/installation/) are required.
76
76
77
77
```bash
78
78
pip3 install iotedgedev
79
79
```
80
80
81
81
> [!NOTE]
82
82
>
83
-
> If you have multiple Python including pre-installed Python 2.7 (for example, on Ubuntu or macOS), make sure you are using`pip3` to install *IoT Edge Dev Tool (iotedgedev)*.
83
+
> If you have multiple Python versions, including pre-installed Python 2.7 (for example, on Ubuntu or macOS), make sure you use`pip3` to install *IoT Edge Dev Tool (iotedgedev)*.
84
84
>
85
85
> For more information setting up your development machine, see [iotedgedev development setup](https://github.com/Azure/iotedgedev/blob/main/docs/environment-setup/manual-dev-machine-setup.md).
86
86
@@ -109,22 +109,17 @@ Install prerequisites specific to the language you're developing in:
109
109
- Install [Node.js](https://nodejs.org). Install [Yeoman](https://www.npmjs.com/package/yo) and the [Azure IoT Edge Node.js Module Generator](https://www.npmjs.com/package/generator-azure-iot-edge-module).
110
110
111
111
# [Python](#tab/python)
112
+
::: zone pivot="iotedge-dev-ext"
112
113
113
-
- Install [Python](https://www.python.org/downloads/) and [Pip](https://pip.pypa.io/en/stable/installation/)
114
-
- Install [Python Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
115
-
- Install the Python-based [Azure IoT Edge Dev Tool](https://pypi.org/project/iotedgedev/) to debug, run, and test your IoT Edge solution. You can alternatively install the Azure IoT Edge Dev Tool using the CLI:
116
-
117
-
```bash
118
-
pip3 install iotedgedev
119
-
```
114
+
Install [Python](https://www.python.org/downloads/) and [Pip](https://pip.pypa.io/en/stable/installation/).
120
115
121
-
> [!NOTE]
122
-
>
123
-
> If you have multiple Python including pre-installed Python 2.7 (for example, on Ubuntu or macOS), make sure you are using `pip3` to install *IoT Edge Dev Tool (iotedgedev)*. For more information setting up your development machine, see [iotedgedev development setup](https://github.com/Azure/iotedgedev/blob/main/docs/environment-setup/manual-dev-machine-setup.md).
116
+
::: zone-end
117
+
118
+
Install the [Python extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python).
124
119
125
120
---
126
121
127
-
To test your module on a device:
122
+
To test your module on a device, you need:
128
123
129
124
- An active IoT Hub with at least one IoT Edge device.
130
125
- A physical IoT Edge device or a virtual device. To create a virtual device in Azure, follow the steps in the quickstart for [Linux](quickstart-linux.md) or [Windows](quickstart.md).
@@ -143,7 +138,7 @@ The [IoT Edge Dev Tool](https://github.com/Azure/iotedgedev) simplifies Azure Io
143
138
mkdir c:\dev\iotedgesolution
144
139
```
145
140
146
-
1. Use the **iotedgedev solution init** command to create a solution and set up your Azure IoT Hub for your development language.
141
+
1. Use the **iotedgedev solution init** command to create a solution and set up your Azure IoT Hub in the development language of your choice.
147
142
148
143
# [C\#](#tab/csharp)
149
144
@@ -211,9 +206,12 @@ After solution creation, these main files are in the solution:
211
206
> [!NOTE]
212
207
> The environment file is only created if you provide an image repository for the module. If you accepted the localhost defaults to test and debug locally, then you don't need to declare environment variables.
213
208
214
-
- Two module deployment files named **deployment.template.json** and **deployment.debug.template.json** list the modules to deploy to your device. By default, the list includes the IoT Edge system modules and two sample modules:
209
+
- Two module deployment files named **deployment.template.json** and **deployment.debug.template.json** list the modules to deploy to your device. By default, the list includes the IoT Edge system modules (edgeAgent and edgeHub) and sample modules such as:
215
210
- **filtermodule** is a sample module that implements a simple filter function.
216
211
- **SimulatedTemperatureSensor** module that simulates data you can use for testing. For more information about how deployment manifests work, see [Learn how to use deployment manifests to deploy modules and establish routes](module-composition.md). For more information on how the simulated temperature module works, see the [SimulatedTemperatureSensor.csproj source code](https://github.com/Azure/iotedge/tree/master/edge-modules/SimulatedTemperatureSensor).
212
+
213
+
> [!NOTE]
214
+
> The exact modules installed may depend on your language of choice.
217
215
218
216
::: zone-end
219
217
@@ -224,13 +222,13 @@ Use Visual Studio Code and the [Azure IoT Edge](https://marketplace.visualstudio
224
222
1. Select **View** > **Command Palette**.
225
223
1. In the command palette, enter and run the command **Azure IoT Edge: New IoT Edge Solution**.
226
224
227
-
:::image type="content" source="./media/how-to-develop-csharp-module/new-solution.png" alt-text="Screenshot of how to run a new IoT Edge solution.":::
225
+
:::image type="content" source="./media/how-to-develop-csharp-module/new-solution.png" alt-text="Screenshot of how to run a new IoT Edge solution." lightbox="./media/how-to-develop-csharp-module/new-solution.png":::
228
226
229
227
1. Browse to the folder where you want to create the new solution and then select **Select folder**.
230
228
1. Enter a name for your solution.
231
229
1. Select a module template for your preferred development language to be the first module in the solution.
232
230
1. Enter a name for your module. Choose a name that's unique within your container registry.
233
-
1. Provide the name of the module's image repository. Visual Studio Code autopopulates the module name with **localhost:5000/<your module name\>**. Replace it with your own registry information. Use **localhost** if you use a local Docker registry for testing. If you use Azure Container Registry, then use sign in server from your registry's settings. The sign-in server looks like **_\<registry name\>_.azurecr.io**. Only replace the **localhost:5000** part of the string so that the final result looks like **\<*registry name*\>.azurecr.io/_\<your module name\>_**.
231
+
1. Provide the name of the module's image repository. Visual Studio Code autopopulates the module name with **localhost:5000/<your module name\>**. Replace it with your own registry information. Use **localhost** if you use a local Docker registry for testing. If you use Azure Container Registry, then use **Login server** from your registry's settings. The sign-in server looks like **_\<registry name\>_.azurecr.io**. Only replace the **localhost:5000** part of the string so that the final result looks like **\<*registry name*\>.azurecr.io/_\<your module name\>_**.
234
232
235
233
:::image type="content" source="./media/how-to-develop-csharp-module/repository.png" alt-text="Screenshot of how to provide a Docker image repository.":::
236
234
@@ -304,11 +302,13 @@ The IoT Edge extension defaults to the latest stable version of the IoT Edge run
304
302
...
305
303
```
306
304
305
+
You might have to change your `.env` file for the variable `RUNTIME_TAG`, instead of changing the manifest.
306
+
307
307
::: zone-end
308
308
309
309
## Add more modules
310
310
311
-
To add more modules to your solution, change to *module* directory.
311
+
To add more modules to your solution, change to the *modules* directory and add them there.
312
312
313
313
```bash
314
314
cd modules
@@ -323,6 +323,8 @@ Run the command **Azure IoT Edge: Add IoT Edge Module** from the command palette
323
323
324
324
::: zone pivot="iotedge-dev-cli"
325
325
326
+
Install the modules using your language of choice.
327
+
326
328
# [C\#](#tab/csharp)
327
329
328
330
1. Install the [.NET IoT Edge C# template](https://github.com/azure/dotnet-template-azure-iot-edge-module/).
@@ -396,13 +398,13 @@ Run the command **Azure IoT Edge: Add IoT Edge Module** from the command palette
396
398
# [Python](#tab/python)
397
399
398
400
1. Create a new directory folder in the *modules* folder and change directory to the new folder. For example, `mkdir pythonmodule` then `cd pythonmodule`.
399
-
1. Get the `cookiecutter-azure-iot-edge-module` from GitHub with one of these methods:
401
+
1. Get the `cookiecutter-azure-iot-edge-module` from GitHub, using one of these methods:
400
402
* From another Bash terminal instance, clone the repository to your desktop with the command:
* Download a ZIP of the contents of the [Cookiecutter Template for Azure IoT Edge Python Module](https://github.com/azure/cookiecutter-azure-iot-edge-module).
405
-
1. Extract (if a ZIP file) the contents of the `{{cookiecutter.module_name}}` folder then copy the files into your new module directory. In this tutorial, we call this new directory **pythonmodule**.
406
+
* Download a ZIP and extract the contents of the [Cookiecutter Template for Azure IoT Edge Python Module](https://github.com/azure/cookiecutter-azure-iot-edge-module).
407
+
1. Copy the contents in the `{{cookiecutter.module_name}}` folder then add these files into your new module directory. In this tutorial, we call this new directory **pythonmodule**.
406
408
407
409
:::image type="content" source="media/how-to-vs-code-develop-module/modules-folder-structure.png" alt-text="Screenshot of the expected folder structure for your I o T Edge solution.":::
408
410
@@ -568,11 +570,11 @@ When you debug modules using this method, your modules are running on top of the
568
570
569
571
### Build and deploy your module to an IoT Edge device
570
572
571
-
In Visual Studio Code, 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. Before deployment, you need to update your Azure Container Registry credentials and your module images with 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).
573
+
In Visual Studio Code, open the *deployment.debug.template.json* deployment manifest file. The [deployment manifest](module-deployment-monitoring.md#deployment-manifest) describes the modules to be configured on the targeted IoT Edge device. Before deployment, you need to update your Azure Container Registry credentials and your module images with 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).
572
574
573
575
::: zone pivot="iotedge-dev-cli"
574
576
575
-
1. If you're using an Azure Container Registry to store your module image, add your credentials to **deployment.debug.template.json**in the *edgeAgent* settings. For example:
577
+
1. If you're using an Azure Container Registry to store your module image, add your credentials to the *edgeAgent* > *settings* > *registryCredentials* section in **deployment.debug.template.json**. Replace **myacr** with your own registry name in both places and provide your password and **Login server** address. For example:
576
578
577
579
```json
578
580
"modulesContent": {
@@ -596,7 +598,7 @@ In Visual Studio Code, open the *deployment.debug.template.json* deployment mani
596
598
...
597
599
```
598
600
599
-
1. Add or replace the following stringified content to the *createOptions* value for each system and custom module listed. Change the values if necessary.
601
+
1. Add or replace the following stringified content to the *createOptions* value for each system (edgeHub and edgeAgent) and custom module (for example, tempSensor) listed. Change the values if necessary.
Push your module image to the local registry or a container registry.
664
+
[Push](https://docs.docker.com/engine/reference/commandline/push/) your module image to the local registry or a container registry.
663
665
664
666
`docker push <ImageName>`
665
667
@@ -803,12 +805,12 @@ The Docker and Moby engines support SSH connections to containers allowing you t
803
805
804
806
:::image type="content" source="media/how-to-vs-code-develop-module/vs-code-breakpoint.png" alt-text="Screenshot of Visual Studio Code attached to a Docker container on a remote device paused at a breakpoint.":::
805
807
> [!NOTE]
806
-
> The preceding example shows how to debug IoT Edge modules on remote containers. It added a remote Docker context and changes to the Docker privileges on the remote device. After you finish debugging your modules, set your Docker context to *default* and remove privileges from your user account.
808
+
> The preceding example shows how to debug IoT Edge modules on remote containers. The example adds a remote Docker context and changes to the Docker privileges on the remote device. After you finish debugging your modules, set your Docker context to *default* and remove privileges from your user account.
807
809
808
810
See this [IoT Developer blog entry](https://devblogs.microsoft.com/iotdev/easily-build-and-debug-iot-edge-modules-on-your-remote-device-with-azure-iot-edge-for-vs-code-1-9-0/) for an example using a Raspberry Pi device.
809
811
810
812
## Next steps
811
813
812
814
After you've built your module, learn how to [deploy Azure IoT Edge modules from Visual Studio Code](how-to-deploy-modules-vscode.md).
813
815
814
-
To develop modules for your IoT Edge devices, [Understand and use Azure IoT Hub SDKs](../iot-hub/iot-hub-devguide-sdks.md).
816
+
To develop modules for your IoT Edge devices, understand and use [Azure IoT Hub SDKs](../iot-hub/iot-hub-devguide-sdks.md).
0 commit comments