Skip to content

Commit 3bd389c

Browse files
committed
Freshness review
1 parent c313300 commit 3bd389c

File tree

1 file changed

+46
-47
lines changed

1 file changed

+46
-47
lines changed

articles/iot-edge/tutorial-deploy-function.md

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: In this tutorial, you develop an Azure Function as an IoT Edge modu
44
author: PatAltimore
55

66
ms.author: patricka
7-
ms.date: 06/10/2024
7+
ms.date: 06/04/2025
88
ms.topic: tutorial
99
ms.service: azure-iot-edge
1010
services: iot-edge
@@ -16,44 +16,43 @@ ms.custom: "mvc, devx-track-csharp"
1616

1717
[!INCLUDE [iot-edge-version-all-supported](includes/iot-edge-version-all-supported.md)]
1818

19-
You can use Azure Functions to deploy code that implements your business logic directly to your Azure IoT Edge devices. This tutorial walks you through creating and deploying an Azure Function that filters sensor data on the simulated IoT Edge device. You use the simulated IoT Edge device that you created in the quickstarts. In this tutorial, you learn how to:
19+
Use Azure Functions to deploy code that runs your business logic directly on your Azure IoT Edge devices. This tutorial shows you how to create and deploy an Azure Function that filters sensor data on a simulated IoT Edge device. Use the simulated IoT Edge device you created in the quickstarts. In this tutorial, you learn how to:
2020

2121
> [!div class="checklist"]
2222
>
23-
> * Use Visual Studio Code to create an Azure Function.
24-
> * Use Visual Studio Code and Docker to create a Docker image and publish it to a container registry.
25-
> * Deploy the module from the container registry to your IoT Edge device.
26-
> * View filtered data.
23+
> * Use Visual Studio Code to create an Azure Function
24+
> * Use Visual Studio Code and Docker to create a Docker image and publish it to a container registry
25+
> * Deploy the module from the container registry to your IoT Edge device
26+
> * View filtered data
2727
28-
:::image type="content" source="./media/tutorial-deploy-function/functions-architecture.png" alt-text="Diagram of function architecture, showing how to stage and deploy a function module.":::
28+
:::image type="content" source="./media/tutorial-deploy-function/functions-architecture.png" alt-text="Diagram that shows function architecture, including how to stage and deploy a function module.":::
2929

30-
The Azure Function that you create in this tutorial filters the temperature data that's generated by your device. The Function only sends messages upstream to Azure IoT Hub when the temperature is above a specified threshold.
30+
The Azure Function you create in this tutorial filters temperature data generated by your device. The function only sends messages upstream to Azure IoT Hub when the temperature is above a specified threshold.
3131

3232
[!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
3333

3434
## Prerequisites
3535

36-
Before beginning this tutorial, do the tutorial to set up your development environment for Linux container development: [Develop Azure IoT Edge modules using Visual Studio Code](tutorial-develop-for-linux.md). After completing that tutorial, you should have the following prerequisites in place:
36+
Before you start this tutorial, follow the tutorial to set up your development environment for Linux container development: [Develop Azure IoT Edge modules using Visual Studio Code](tutorial-develop-for-linux.md). When you finish, you have the following prerequisites in place:
3737

38-
* A free or standard-tier [IoT Hub](../iot-hub/iot-hub-create-through-portal.md) in Azure.
39-
* An AMD64 device running Azure IoT Edge with Linux containers. You can use the quickstart to set up a [Linux device](quickstart-linux.md) or [Windows device](quickstart.md).
40-
* A container registry, like [Azure Container Registry](/azure/container-registry/).
41-
* [Visual Studio Code](https://code.visualstudio.com/) configured with the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge) and
42-
[Azure IoT Hub](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) extensions. The *Azure IoT Edge tools for Visual Studio Code* extension is in [maintenance mode](https://github.com/microsoft/vscode-azure-iot-edge/issues/639).
43-
* Download and install a [Docker compatible container management system](support.md#container-engines) on your development machine. Configure it to run Linux containers.
38+
* A free or standard-tier [IoT Hub](../iot-hub/iot-hub-create-through-portal.md) in Azure
39+
* An AMD64 device running Azure IoT Edge with Linux containers. Use the quickstart to set up a [Linux device](quickstart-linux.md) or [Windows device](quickstart.md).
40+
* A container registry, like [Azure Container Registry](/azure/container-registry/)
41+
* [Visual Studio Code](https://code.visualstudio.com/) set up with the [Azure IoT Edge](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-edge) and [Azure IoT Hub](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) extensions. The *Azure IoT Edge tools for Visual Studio Code* extension is in [maintenance mode](https://github.com/microsoft/vscode-azure-iot-edge/issues/639).
42+
* Download and install a [Docker compatible container management system](support.md#container-engines) on your development machine. Set it to run Linux containers.
4443

45-
To develop an IoT Edge module with Azure Functions, install additional prerequisites on your development machine:
44+
To develop an IoT Edge module with Azure Functions, install these additional prerequisites on your development machine:
4645

47-
* [C# for Visual Studio Code (powered by OmniSharp) extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp).
48-
* [The .NET Core SDK](https://dotnet.microsoft.com/download).
46+
* [C# for Visual Studio Code (powered by OmniSharp) extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
47+
* [The .NET Core SDK](https://dotnet.microsoft.com/download)
4948

5049
## Create a function project
5150

52-
The Azure IoT Edge for Visual Studio Code that you installed in the prerequisites provides management capabilities and some code templates. In this section, you use Visual Studio Code to create an IoT Edge solution that contains an Azure Function.
51+
Azure IoT Edge for Visual Studio Code gives you management capabilities and code templates. In this section, you use Visual Studio Code to create an IoT Edge solution with an Azure Function.
5352

5453
### Create a new project
5554

56-
Follow these steps to create a C# Function solution template that's customizable.
55+
Follow these steps to create a customizable C# Function solution template.
5756

5857
1. Open Visual Studio Code on your development machine.
5958

@@ -71,32 +70,32 @@ Follow these steps to create a C# Function solution template that's customizable
7170

7271
### Add your registry credentials
7372

74-
The environment file of your solution stores the credentials for your container registry and shares them with the IoT Edge runtime. The runtime needs these credentials to pull your private images onto your IoT Edge device.
73+
The environment file in your solution stores the credentials for your container registry and shares them with the IoT Edge runtime. The runtime needs these credentials to pull your private images onto your IoT Edge device.
7574

76-
The IoT Edge extension in Visual Studio Code tries to pull your container registry credentials from Azure and populate them in the environment file. Check to see if your credentials are already in the file. If not, add them now:
75+
The IoT Edge extension in Visual Studio Code tries to pull your container registry credentials from Azure and populate them in the environment file. Check if your credentials are already in the file. If not, add them now:
7776

7877
1. In the Visual Studio Code explorer, open the `.env` file.
79-
2. Update the fields with the **username** and **password** values that you copied from your Azure container registry. You can find them again by going to your container registry in Azure and looking on the **Settings** > **Access keys** page.
78+
1. Update the fields with the **username** and **password** values you copied from your Azure container registry. To find them again, go to your container registry in Azure and look on the **Settings** > **Access keys** page.
8079
3. Save this file.
8180

8281
>[!NOTE]
83-
>This tutorial uses admin login credentials for Azure Container Registry, which are convenient for development and test scenarios. When you're ready for production scenarios, we recommend a least-privilege authentication option like service principals. For more information, see [Manage access to your container registry](production-checklist.md#manage-access-to-your-container-registry).
82+
>This tutorial uses admin login credentials for Azure Container Registry, which are convenient for development and test scenarios. For production, use a least-privilege authentication option like service principals. For more information, see [Manage access to your container registry](production-checklist.md#manage-access-to-your-container-registry).
8483
8584
### Set target architecture to AMD64
8685

87-
Running Azure Functions modules on IoT Edge is supported only on Linux AMD64 based containers. The default target architecture for Visual Studio Code is Linux AMD64, but we set it explicitly to Linux AMD64 here.
86+
Azure Functions modules on IoT Edge are supported only on Linux AMD64-based containers. The default target architecture for Visual Studio Code is Linux AMD64, but you set it explicitly to Linux AMD64 here.
8887

8988
1. Open the command palette and search for **Azure IoT Edge: Set Default Target Platform for Edge Solution**.
9089

9190
2. In the command palette, select the AMD64 target architecture from the list of options.
9291

9392
### Update the module with custom code
9493

95-
Let's add some additional code so your **CSharpFunction** module processes the messages at the edge before forwarding them to IoT Hub.
94+
Add some code so your **CSharpFunction** module processes messages at the edge before forwarding them to IoT Hub.
9695

9796
1. In the Visual Studio Code explorer, open **modules** > **CSharpFunction** > **CSharpFunction.cs**.
9897

99-
1. Replace the contents of the **CSharpFunction.cs** file with the following code. This code receives telemetry about ambient and machine temperature, and only forwards the message on to IoT Hub if the machine temperature is above a defined threshold.
98+
1. Replace the contents of the **CSharpFunction.cs** file with the following code. This code receives telemetry about ambient and machine temperature, and forwards the message to IoT Hub only if the machine temperature is above a defined threshold.
10099

101100
```csharp
102101
using System;
@@ -173,60 +172,60 @@ Let's add some additional code so your **CSharpFunction** module processes the m
173172

174173
## Build and push your IoT Edge solution
175174

176-
In the previous section, you created an IoT Edge solution and modified the **CSharpFunction** to filter out messages with reported machine temperatures below the acceptable threshold. Now you need to build the solution as a container image and push it to your container registry.
175+
In the previous section, you created an IoT Edge solution and changed the **CSharpFunction** to filter out messages with reported machine temperatures below the acceptable threshold. Now build the solution as a container image and push it to your container registry.
177176

178-
1. Open the Visual Studio Code integrated terminal by selecting **View** > **Terminal**.
177+
1. Open the Visual Studio Code integrated terminal. Select **View** > **Terminal**.
179178

180-
2. Sign in to Docker by entering the following command in the terminal. Sign in with the username, password, and login server from your Azure container registry. You can retrieve these values from the **Access keys** section of your registry in the Azure portal.
179+
1. Sign in to Docker in the terminal. Use the username, password, and login server from your Azure container registry. Get these values from the **Access keys** section of your registry in the Azure portal.
181180

182181
```bash
183182
docker login -u <ACR username> -p <ACR password> <ACR login server>
184183
```
185184

186-
You may receive a security warning recommending the use of `--password-stdin`. While that best practice is recommended for production scenarios, it's outside the scope of this tutorial. For more information, see the [docker login](https://docs.docker.com/engine/reference/commandline/login/#provide-a-password-using-stdin) reference.
185+
You can receive a security warning recommending the use of `--password-stdin`. While that best practice is recommended for production scenarios, it's outside the scope of this tutorial. For more information, see the [docker login](https://docs.docker.com/engine/reference/commandline/login/#provide-a-password-using-stdin) reference.
187186

188-
3. In the Visual Studio Code explorer, right-click the **deployment.template.json** file and select **Build and Push IoT Edge Solution**.
187+
1. In the Visual Studio Code explorer, right-click the **deployment.template.json** file, then select **Build and Push IoT Edge Solution**.
189188

190-
The build and push command starts three operations. First, it creates a new folder in the solution called **config** that holds the full deployment manifest, which is built out of information in the deployment template and other solution files. Second, it runs `docker build` to build the container image based on the appropriate dockerfile for your target architecture. Then, it runs `docker push` to push the image repository to your container registry.
189+
The build and push command starts three operations. First, it creates a new folder in the solution called **config** that has the full deployment manifest, which is built from the deployment template and other solution files. Second, it runs `docker build` to build the container image based on the appropriate Dockerfile for your target architecture. Then, it runs `docker push` to push the image repository to your container registry.
191190

192-
This process may take several minutes the first time, but is faster the next time that you run the commands.
191+
This process can take several minutes the first time, but it's faster the next time you run the commands.
193192

194193
## View your container image
195194

196-
Visual Studio Code outputs a success message when your container image is pushed to your container registry. If you want to confirm the successful operation for yourself, you can view the image in the registry.
195+
Visual Studio Code shows a success message when your container image is pushed to your container registry. To confirm the operation, view the image in the registry.
197196

198-
1. In the Azure portal, browse to your Azure container registry.
197+
1. In the Azure portal, go to your Azure container registry.
199198
2. Select **Services** > **Repositories**.
200-
3. You should see the **csharpfunction** repository in the list. Select this repository to see more details.
201-
4. In the **Tags** section, you should see the **0.0.1-amd64** tag. This tag indicates the version and platform of the image that you built. These values are set in the module.json file in the CSharpFunction folder.
199+
3. You see the **csharpfunction** repository in the list. Select this repository to view more details.
200+
4. In the **Tags** section, you see the **0.0.1-amd64** tag. This tag shows the version and platform of the image you built. These values are set in the *module.json* file in the *CSharpFunction* folder.
202201

203202
## Deploy and run the solution
204203

205-
You can use the Azure portal to deploy your Function module to an IoT Edge device like you did in the quickstart. You can also deploy and monitor modules from within Visual Studio Code. The following sections use the Azure IoT Edge and IoT Hub for Visual Studio Code that was listed in the prerequisites. Install the extensions now, if you haven't already.
204+
Use the Azure portal to deploy your Function module to an IoT Edge device like in the quickstart. You can also deploy and monitor modules from Visual Studio Code. The following sections use the Azure IoT Edge and IoT Hub for Visual Studio Code extensions listed in the prerequisites. Install the extensions now if you haven't already.
206205

207-
1. In the Visual Studio Code explorer, under the **Azure IoT Hub** section, expand **Devices** to see your list of IoT devices.
206+
1. In the Visual Studio Code explorer, under the **Azure IoT Hub** section, expand **Devices** to see the list of IoT devices.
208207

209208
2. Right-click the name of your IoT Edge device, and then select **Create Deployment for Single Device**.
210209

211-
3. Browse to the solution folder that contains the **CSharpFunction**. Open the config folder, select the **deployment.amd64.json** file, and then choose **Select Edge Deployment Manifest**.
210+
3. Go to the solution folder that has the **CSharpFunction**. Open the config folder, select the **deployment.amd64.json** file, and then choose **Select Edge Deployment Manifest**.
212211

213-
4. Under your device, expand **Modules** to see a list of deployed and running modules. Select the refresh button. You should see the new **CSharpFunction** running along with the **SimulatedTemperatureSensor** module and the **$edgeAgent** and **$edgeHub**.
212+
4. Under your device, expand **Modules** to see a list of deployed and running modules. Select the refresh button. You can see the new **CSharpFunction** running along with the **SimulatedTemperatureSensor** module, **$edgeAgent**, and **$edgeHub**.
214213

215-
It may take a few moments for the new modules to show up. Your IoT Edge device has to retrieve its new deployment information from IoT Hub, start the new containers, and then report the status back to IoT Hub.
214+
It can take a few moments for the new modules to show up. The IoT Edge device retrieves its new deployment information from IoT Hub, starts the new containers, and then reports the status back to IoT Hub.
216215

217216
:::image type="content" source="./media/tutorial-deploy-function/view-modules.png" alt-text="Screenshot showing how to view deployed modules in Visual Studio Code.":::
218217

219218
## View the generated data
220219

221-
You can see all of the messages that arrive at your IoT hub from all your devices by running **Azure IoT Hub: Start Monitoring Built-in Event Endpoint** in the command palette. To stop monitoring messages, run the command **Azure IoT Hub: Stop Monitoring Built-in Event Endpoint** in the command palette.
220+
See all messages that arrive at your IoT hub from your devices by running **Azure IoT Hub: Start Monitoring Built-in Event Endpoint** in the command palette. To stop monitoring messages, run **Azure IoT Hub: Stop Monitoring Built-in Event Endpoint** in the command palette.
222221

223-
You can also filter the view to see all of the messages that arrive at your IoT hub from a specific device. Right-click the device in the **Azure IoT Hub** > **Devices** section of the Visual Studio Code explorer and select **Start Monitoring Built-in Event Endpoint**.
222+
To filter the view and see messages from a specific device, right-click the device in the **Azure IoT Hub** > **Devices** section of the Visual Studio Code explorer, and select **Start Monitoring Built-in Event Endpoint**.
224223

225224
## Clean up resources
226225

227-
If you plan to continue to the next recommended article, you can keep the resources and configurations that you created and reuse them. You can also keep using the same IoT Edge device as a test device.
226+
If you plan to continue to the next recommended article, keep the resources and configurations you created and reuse them. You can also keep using the same IoT Edge device as a test device.
228227

229-
Otherwise, you can delete the local configurations and the Azure resources that you created in this article to avoid charges.
228+
Otherwise, delete the local configurations and the Azure resources you created in this article to avoid charges.
230229

231230
[!INCLUDE [iot-edge-clean-up-cloud-resources](includes/iot-edge-clean-up-cloud-resources.md)]
232231

0 commit comments

Comments
 (0)