Skip to content

Commit e842d27

Browse files
committed
Formatting
1 parent 51a5f63 commit e842d27

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

articles/iot-edge/tutorial-develop-for-linux.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This tutorial walks through setting up your development machine and
44
author: PatAltimore
55

66
ms.author: patricka
7-
ms.date: 03/30/2023
7+
ms.date: 03/31/2023
88
ms.topic: tutorial
99
ms.service: iot-edge
1010
services: iot-edge
@@ -36,16 +36,15 @@ The IoT Edge module that you create in this tutorial filters the temperature dat
3636
A development machine:
3737

3838
* Use your own computer or a virtual machine.
39-
* Your development machine must support [nested virtualization](/virtualization/hyper-v-on-windows/user-guide/nested-virtualization) for running a container engine that you'll install in the next section.
39+
* Your development machine must support [nested virtualization](/virtualization/hyper-v-on-windows/user-guide/nested-virtualization) for running a container engine.
4040
* Most operating systems that can run a container engine can be used to develop IoT Edge modules for Linux devices. This tutorial uses a Windows computer, but points out known differences on macOS or Linux.
4141
* Install [Git](https://git-scm.com/), to pull module template packages later in this tutorial.
42-
4342
* Install [Visual Studio Code](https://code.visualstudio.com/)
4443
* Install the [Azure CLI](/cli/azure/install-azure-cli).
4544

4645
An Azure IoT Edge device:
4746

48-
* You shoul run IoT Edge on a separate device. This distinction between development machine and IoT Edge device simulates a true deployment scenario and helps keep the different concepts separate.
47+
* You should run IoT Edge on a separate device. This distinction between development machine and IoT Edge device simulates a true deployment scenario and helps keep the different concepts separate.
4948
Use the quickstart article [Deploy code to a Linux Device](quickstart-linux.md) to create an IoT Edge device in Azure.
5049

5150
Cloud resources:
@@ -140,37 +139,36 @@ Install tools specific to the language you're developing in:
140139

141140
# [C\#](#tab/csharp)
142141

143-
- Install [.NET Core SDK](https://dotnet.microsoft.com/download)
144-
- Install [C# Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
142+
* [.NET Core SDK](https://dotnet.microsoft.com/download)
143+
* [C# Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
145144

146145
# [C](#tab/c)
147146

148-
- Install [C/C++ Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
149-
150-
Installing the Azure IoT C SDK isn't required for this tutorial, but can provide helpful functionality like intellisense and reading program definitions. For installation information, see [Azure IoT C SDKs and Libraries](https://github.com/Azure/azure-iot-sdk-c).
147+
* [C/C++ Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
148+
* Installing the Azure IoT C SDK isn't required for this tutorial, but can provide helpful functionality like intellisense and reading program definitions. For installation information, see [Azure IoT C SDKs and Libraries](https://github.com/Azure/azure-iot-sdk-c).
151149

152150
# [Java](#tab/java)
153151

154-
- Install [Java SE Development Kit 11](/azure/developer/java/fundamentals/java-support-on-azure) and [Maven](https://maven.apache.org/). You need to [set the `JAVA_HOME` environment variable](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/) to point to your JDK installation.
155-
- [Maven](https://maven.apache.org/)
156-
- Install [Java Extension Pack for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
152+
* [Java SE Development Kit 11](/azure/developer/java/fundamentals/java-support-on-azure) and [Maven](https://maven.apache.org/). You need to [set the `JAVA_HOME` environment variable](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/) to point to your JDK installation.
153+
* [Maven](https://maven.apache.org/)
154+
* [Java Extension Pack for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
157155

158156
>[!TIP]
159157
>The Java and Maven installation processes add environment variables to your system. Restart any open Visual Studio Code terminal, PowerShell, or command prompt instances after completing installation. This step ensures that these utilities can recognize the Java and Maven commands going forward.
160158
161159
# [Node.js](#tab/node)
162160

163-
- Install [Node.js](https://nodejs.org).
164-
- Install [Yeoman](https://www.npmjs.com/package/yo)
165-
- Install [Azure IoT Edge Node.js Module Generator](https://www.npmjs.com/package/generator-azure-iot-edge-module).
161+
* [Node.js](https://nodejs.org).
162+
* [Yeoman](https://www.npmjs.com/package/yo)
163+
* [Azure IoT Edge Node.js Module Generator](https://www.npmjs.com/package/generator-azure-iot-edge-module).
166164

167165
# [Python](#tab/python)
168166

169167
To develop an IoT Edge module in Python, install the following additional prerequisites on your development machine:
170168

171-
- Install [Python](https://www.python.org/downloads/) and [Pip](https://pip.pypa.io/en/stable/installation/).
172-
- Install [Cookiecutter](https://github.com/audreyr/cookiecutter).
173-
- Install the [Python extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python).
169+
* [Python](https://www.python.org/downloads/) and [Pip](https://pip.pypa.io/en/stable/installation/).
170+
* [Cookiecutter](https://github.com/audreyr/cookiecutter).
171+
* [Python extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python).
174172

175173
>[!Note]
176174
>Ensure that your `bin` folder is on your path for your platform. Typically `~/.local/` for UNIX and macOS, or `%APPDATA%\Python` on Windows.
@@ -402,7 +400,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
402400

403401
1. Find the **Init** function. This function creates and configures a **ModuleClient** object, which allows the module to connect to the local Azure IoT Edge runtime to send and receive messages. After creating the **ModuleClient**, the code reads the **temperatureThreshold** value from the module twin's desired properties. The code registers a callback to receive messages from an IoT Edge hub via an endpoint called **input1**.
404402
405-
Replace the **SetInputMessageHandlerAsync** method with a new one that updates the name of the endpoint and the method that is called when input arrives. Also, add a **SetDesiredPropertyUpdateCallbackAsync** method for updates to the desired properties. To make this change, replace the last line of the **Init** method with the following code:
403+
Replace the **SetInputMessageHandlerAsync** method with a new one that updates the name of the endpoint and the method that's called when input arrives. Also, add a **SetDesiredPropertyUpdateCallbackAsync** method for updates to the desired properties. To make this change, replace the last line of the **Init** method with the following code:
406404

407405
```csharp
408406
// Register a callback for messages that are received by the module.
@@ -507,7 +505,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
507505
}
508506
```
509507
510-
1. Save the ModuleBackgroundService.cs file.
508+
1. Save the **ModuleBackgroundService.cs** file.
511509
512510
1. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
513511
@@ -537,7 +535,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
537535
538536
1. Download the [Parson GitHub repository](https://github.com/kgabis/parson). Copy the **parson.c** and **parson.h** files into the **filtermodule** folder.
539537
540-
2. Open **modules** > **filtermodule** > **CMakeLists.txt**. At the top of the file, import the Parson files as a library called **my_parson**.
538+
1. Open **modules** > **filtermodule** > **CMakeLists.txt**. At the top of the file, import the Parson files as a library called **my_parson**.
541539
542540
```txt
543541
add_library(my_parson
@@ -546,11 +544,11 @@ The sample C# code that comes with the project template uses the [ModuleClient C
546544
)
547545
```
548546
549-
3. Add `my_parson` to the list of libraries in the **target_link_libraries** function of CMakeLists.txt.
547+
1. Add `my_parson` to the list of libraries in the **target_link_libraries** function of CMakeLists.txt.
550548
551-
4. Save the **CMakeLists.txt** file.
549+
1. Save the **CMakeLists.txt** file.
552550
553-
5. Open **modules** > **filtermodule** > **main.c**. At the bottom of the list of include statements, add a new one to include `parson.h` for JSON support:
551+
1. Open **modules** > **filtermodule** > **main.c**. At the bottom of the list of include statements, add a new one to include `parson.h` for JSON support:
554552
555553
```c
556554
#include "parson.h"
@@ -701,7 +699,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
701699
}
702700
```
703701
704-
1. Save the main.c file.
702+
1. Save the **main.c** file.
705703
706704
1. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
707705
@@ -721,7 +719,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
721719
722720
1. In the Visual Studio Code explorer, open **modules** > **filtermodule** > **src** > **main** > **java** > **com** > **edgemodule** > **App.java**.
723721
724-
2. Add the following code at the top of the file to import new referenced classes.
722+
1. Add the following code at the top of the file to import new referenced classes.
725723
726724
```java
727725
import java.io.StringReader;
@@ -738,14 +736,14 @@ The sample C# code that comes with the project template uses the [ModuleClient C
738736
import com.microsoft.azure.sdk.iot.device.DeviceTwin.TwinPropertyCallBack;
739737
```
740738
741-
3. Add the following definition into class **App**. This variable sets a temperature threshold. The measured machine temperature won't be reported to IoT Hub until it goes over this value.
739+
1. Add the following definition into class **App**. This variable sets a temperature threshold. The measured machine temperature won't be reported to IoT Hub until it goes over this value.
742740
743741
```java
744742
private static final String TEMP_THRESHOLD = "TemperatureThreshold";
745743
private static AtomicLong tempThreshold = new AtomicLong(25);
746744
```
747745
748-
4. Replace the execute method of **MessageCallbackMqtt** with the following code. This method is called whenever the module receives an MQTT message from the IoT Edge hub. It filters out messages that report temperatures below the temperature threshold set via the module twin.
746+
1. Replace the execute method of **MessageCallbackMqtt** with the following code. This method is called whenever the module receives an MQTT message from the IoT Edge hub. It filters out messages that report temperatures below the temperature threshold set via the module twin.
749747
750748
```java
751749
protected static class MessageCallbackMqtt implements MessageCallback {
@@ -779,7 +777,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
779777
}
780778
```
781779
782-
5. Add the following two static inner classes into class **App**. These classes update the tempThreshold variable when the module twin's desired property changes. All modules have their own module twin, which lets you configure the code that's running inside a module directly from the cloud.
780+
1. Add the following two static inner classes into class **App**. These classes update the tempThreshold variable when the module twin's desired property changes. All modules have their own module twin, which lets you configure the code that's running inside a module directly from the cloud.
783781
784782
```java
785783
protected static class DeviceTwinStatusCallBack implements IotHubEventCallback {
@@ -807,7 +805,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
807805
}
808806
```
809807
810-
6. Add the following lines in to **main** method after **client.open()** to subscribe the module twin updates.
808+
1. Add the following lines in to **main** method after **client.open()** to subscribe the module twin updates.
811809
812810
```java
813811
client.startTwin(new DeviceTwinStatusCallBack(), null, new OnProperty(), null);
@@ -820,11 +818,11 @@ The sample C# code that comes with the project template uses the [ModuleClient C
820818
client.getTwin();
821819
```
822820
823-
7. Save the **App.java** file.
821+
1. Save the **App.java** file.
824822
825-
8. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
823+
1. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
826824
827-
9. Add the **filtermodule** module twin to the deployment manifest. Insert the following JSON content at the bottom of the **moduleContent** section, after the **$edgeHub** module twin:
825+
1. Add the **filtermodule** module twin to the deployment manifest. Insert the following JSON content at the bottom of the **moduleContent** section, after the **$edgeHub** module twin:
828826
829827
```json
830828
"filtermodule": {
@@ -834,20 +832,20 @@ The sample C# code that comes with the project template uses the [ModuleClient C
834832
}
835833
```
836834
837-
10. Save the **deployment.template.json** file.
835+
1. Save the **deployment.template.json** file.
838836
839837
840838
# [Node.js](#tab/node)
841839
842840
1. In the Visual Studio Code explorer, open **modules** > **filtermodule** > **app.js**.
843841
844-
2. Add a temperature threshold variable below required node modules. The temperature threshold sets the value that the measured temperature must exceed in order for the data to be sent to IoT Hub.
842+
1. Add a temperature threshold variable below required node modules. The temperature threshold sets the value that the measured temperature must exceed in order for the data to be sent to IoT Hub.
845843
846844
```javascript
847845
var temperatureThreshold = 25;
848846
```
849847
850-
3. Replace the entire `PipeMessage` function with the `FilterMessage` function.
848+
1. Replace the entire `PipeMessage` function with the `FilterMessage` function.
851849
852850
```javascript
853851
// This function filters out messages that report temperatures below the temperature threshold.
@@ -868,15 +866,15 @@ The sample C# code that comes with the project template uses the [ModuleClient C
868866
869867
```
870868
871-
4. Replace the function name `pipeMessage` with `filterMessage` in `client.on()` function.
869+
1. Replace the function name `pipeMessage` with `filterMessage` in `client.on()` function.
872870
873871
```javascript
874872
client.on('inputMessage', function (inputName, msg) {
875873
filterMessage(client, inputName, msg);
876874
});
877875
```
878876
879-
5. Copy the following code snippet into the `client.open()` function callback, after `client.on()` inside the `else` statement. This function is invoked when the desired properties are updated.
877+
1. Copy the following code snippet into the `client.open()` function callback, after `client.on()` inside the `else` statement. This function is invoked when the desired properties are updated.
880878
881879
```javascript
882880
client.getTwin(function (err, twin) {
@@ -892,11 +890,11 @@ The sample C# code that comes with the project template uses the [ModuleClient C
892890
});
893891
```
894892
895-
6. Save the **app.js** file.
893+
1. Save the **app.js** file.
896894
897-
7. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
895+
1. In the Visual Studio Code explorer, open the **deployment.template.json** file in your IoT Edge solution workspace.
898896
899-
8. Add the filtermodule module twin to the deployment manifest. Insert the following JSON content at the bottom of the `moduleContent` section, after the `$edgeHub` module twin:
897+
1. Add the filtermodule module twin to the deployment manifest. Insert the following JSON content at the bottom of the `moduleContent` section, after the `$edgeHub` module twin:
900898
901899
```json
902900
"filtermodule": {
@@ -906,7 +904,7 @@ The sample C# code that comes with the project template uses the [ModuleClient C
906904
}
907905
```
908906
909-
9. Save the **deployment.template.json** file.
907+
1. Save the **deployment.template.json** file.
910908
911909
# [Python](#tab/python)
912910
@@ -1098,7 +1096,9 @@ docker build --rm -f "./modules/filtermodule/Dockerfile.amd64.debug" -t myacr.az
10981096
10991097
[Push](https://docs.docker.com/engine/reference/commandline/push/) your module image to the local registry or a container registry.
11001098
1101-
`docker push <ImageName>`
1099+
```bash
1100+
docker push <ImageName>
1101+
```
11021102
11031103
For example:
11041104
@@ -1179,7 +1179,7 @@ To further verify what the build and push command did, go to the [Azure portal](
11791179
11801180
In your container registry, select **Repositories** then **samplemodule**. Verify that both versions of the image push to the registry.
11811181
1182-
:::image type="content" source="./media/tutorial-develop-for-linux/view-repository-versions.png" alt-text="Screenshot of where to view both image versions in your container registry." lightbox="./media/tutorial-develop-for-linux/view-repository-versions.png":::
1182+
:::image type="content" source="./media/tutorial-develop-for-linux/view-repository-versions.png" alt-text="Screenshot of where to view both image versions in your container registry." lightbox="./media/tutorial-develop-for-linux/view-repository-versions.png":::
11831183
11841184
<!--Alternative steps: Use Visual Studio Code Docker tools to view ACR images with tags-->
11851185
@@ -1214,15 +1214,15 @@ az iot edge set-modules --hub-name my-iot-hub --device-id my-device --content ./
12141214
12151215
1. In the Visual Studio Code explorer, under the **Azure IoT Hub** section, expand **Devices** to see your list of IoT devices.
12161216
1217-
2. Right-click the IoT Edge device that you want to deploy to, then select **Create Deployment for Single Device**.
1217+
1. Right-click the IoT Edge device that you want to deploy to, then select **Create Deployment for Single Device**.
12181218
12191219
:::image type="content" source="./media/tutorial-develop-for-linux/create-deployment.png" alt-text="Screenshot showing how to create a deployment for a single device.":::
12201220
1221-
3. In the file explorer, navigate into the **config** folder then select the **deployment.amd64.json** file.
1221+
1. In the file explorer, navigate into the **config** folder then select the **deployment.amd64.json** file.
12221222
12231223
Don't use the deployment.template.json file, which doesn't have the container registry credentials or module image values in it. If you target a Linux ARM32 device, the deployment manifest's name is **deployment.arm32v7.json**.
12241224
1225-
4. Under your device, expand **Modules** to see a list of deployed and running modules. Select the refresh button. You should see the new SimulatedTemperatureSensor and SampleModule modules running on your device.
1225+
1. Under your device, expand **Modules** to see a list of deployed and running modules. Select the refresh button. You should see the new SimulatedTemperatureSensor and SampleModule modules running on your device.
12261226
12271227
It may take a few minutes for the modules to start. The IoT Edge runtime needs to receive its new deployment manifest, pull down the module images from the container runtime, then start each new module.
12281228
@@ -1234,7 +1234,7 @@ The SampleModule code receives messages through its input queue and passes them
12341234
12351235
1. In the Visual Studio Code explorer, right-click the IoT Edge device that you want to monitor, then select **Start Monitoring Built-in Event Endpoint**.
12361236
1237-
2. Watch the output window in Visual Studio Code to see messages arriving at your IoT hub.
1237+
1. Watch the output window in Visual Studio Code to see messages arriving at your IoT hub.
12381238
12391239
:::image type="content" source="./media/tutorial-develop-for-linux/view-d2c-messages.png" alt-text="Screenshot showing where to view incoming device to cloud messages.":::
12401240

0 commit comments

Comments
 (0)