Skip to content

Commit 7ceac23

Browse files
committed
tested article, made small changes
1 parent 27ded7b commit 7ceac23

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed
692 Bytes
Loading

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

Lines changed: 23 additions & 27 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: 05/11/2022
7+
ms.date: 3/22/2023
88
ms.topic: tutorial
99
ms.service: iot-edge
1010
services: iot-edge
@@ -33,16 +33,16 @@ The Azure Function that you create in this tutorial filters the temperature data
3333

3434
## Prerequisites
3535

36-
Before beginning this tutorial, you should have gone through the previous tutorial to set up your development environment for Linux container development: [Develop IoT Edge modules using Linux containers](tutorial-develop-for-linux.md). By completing that tutorial, you should have the following prerequisites in place:
36+
Before beginning this tutorial, do the tutorial to set up your development environment for Linux container development: [Develop IoT Edge modules using Linux containers](tutorial-develop-for-linux.md). After completing that tutorial, you should have the following prerequisites in place:
3737

3838
* 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 quickstarts to set up a [Linux device](quickstart-linux.md) or [Windows device](quickstart.md).
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).
4040
* A container registry, like [Azure Container Registry](../container-registry/index.yml).
4141
* [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
4242
[Azure IoT Hub](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) extensions.
4343
* Download and install a [Docker compatible container management system](support.md#container-engines) on your development machine. Configure it to run Linux containers.
4444

45-
To develop an IoT Edge module in with Azure Functions, install the following additional prerequisites on your development machine:
45+
To develop an IoT Edge module with Azure Functions, install additional prerequisites on your development machine:
4646

4747
* [C# for Visual Studio Code (powered by OmniSharp) extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp).
4848
* [The .NET Core SDK](https://dotnet.microsoft.com/download).
@@ -53,32 +53,30 @@ The Azure IoT Edge for Visual Studio Code that you installed in the prerequisite
5353

5454
### Create a new project
5555

56-
Create a C# Function solution template that you can customize with your own code.
56+
Follow these steps to create a C# Function solution template that's customizable.
5757

5858
1. Open Visual Studio Code on your development machine.
5959

6060
2. Open the Visual Studio Code command palette by selecting **View** > **Command Palette**.
6161

62-
3. In the command palette, enter and run the command **Azure IoT Edge: New IoT Edge solution**. Follow the prompts in the command palette to create your solution.
62+
3. In the command palette, add and run the command **Azure IoT Edge: New IoT Edge solution**. Follow these prompts in the command palette to create your solution:
6363

64-
| Field | Value |
65-
| ----- | ----- |
66-
| Select folder | Choose the location on your development machine for Visual Studio Code to create the solution files. |
67-
| Provide a solution name | Enter a descriptive name for your solution, like **FunctionSolution**, or accept the default. |
68-
| Select module template | Choose **Azure Functions - C#**. |
69-
| Provide a module name | Name your module **CSharpFunction**. |
70-
| Provide Docker image repository for the module | An image repository includes the name of your container registry and the name of your container image. Your container image is prepopulated from the last step. Replace **localhost:5000** with the **Login server** value from your Azure container registry. You can retrieve the Login server from the Overview page of your container registry in the Azure portal. The final string looks like \<registry name\>.azurecr.io/CSharpFunction. |
64+
* Select a folder: choose the location on your development machine for Visual Studio Code to create the solution files.
65+
* Provide a solution name: add a descriptive name for your solution, like **FunctionSolution**, or accept the default.|
66+
* Select a module template: choose **Azure Functions - C#**.
67+
* Provide a module name | Name your module **CSharpFunction**.
68+
* Provide a Docker image repository for the module. An image repository includes the name of your container registry and the name of your container image. Your container image is pre-populated from the last step. Replace **localhost:5000** with the **Login server** value from your Azure container registry. You can retrieve the **Login server** from the **Overview** page of your container registry in the Azure portal. The final string looks like \<registry name\>.azurecr.io/csharpfunction.
7169

72-
:::image type="content" source="./media/tutorial-deploy-function/repository.png" alt-text="Screenshot showing where to choose your Docker image repository in Visual Studio Code.":::
70+
:::image type="content" source="./media/tutorial-deploy-function/repository.png" alt-text="Screenshot showing where to add your Docker image repository name in Visual Studio Code.":::
7371

7472
### Add your registry credentials
7573

76-
The environment file 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 the IoT Edge device.
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.
7775

78-
The IoT Edge extension tries to pull your container registry credentials from Azure and populate them in the environment file. Check to see if your credentials are already included. If not, add them now:
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:
7977

80-
1. In the Visual Studio Code explorer, open the .env file.
81-
2. Update the fields with the **username** and **password** values that you copied from your Azure container registry.
78+
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.
8280
3. Save this file.
8381

8482
>[!NOTE]
@@ -88,15 +86,15 @@ The IoT Edge extension tries to pull your container registry credentials from Az
8886

8987
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 will set it explicitly to Linux AMD64 here.
9088

91-
1. Open the command palette and search for **Azure IoT Edge: Set Default Target Platform for Edge Solution**, or select the shortcut icon in the side bar at the bottom of the window.
89+
1. Open the command palette and search for **Azure IoT Edge: Set Default Target Platform for Edge Solution**.
9290

9391
2. In the command palette, select the AMD64 target architecture from the list of options.
9492

9593
### Update the module with custom code
9694

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

99-
1. In Visual Studio Code, open **modules** > **CSharpFunction** > **CSharpFunction.cs**.
97+
1. In the Visual Studio Code explorer, open **modules** > **CSharpFunction** > **CSharpFunction.cs**.
10098

10199
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.
102100

@@ -198,13 +196,13 @@ In the previous section, you created an IoT Edge solution and modified the **CSh
198196
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.
199197

200198
1. In the Azure portal, browse to your Azure container registry.
201-
2. Select **Repositories**.
199+
2. Select **Services** > **Repositories**.
202200
3. You should see the **csharpfunction** repository in the list. Select this repository to see more details.
203201
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.
204202

205203
## Deploy and run the solution
206204

207-
You can use the Azure portal to deploy your Function module to an IoT Edge device like you did in the quickstarts. 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 extension now, if you didn't already.
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.
208206

209207
1. In the Visual Studio Code explorer, under the **Azure IoT Hub** section, expand **Devices** to see your list of IoT devices.
210208

@@ -220,11 +218,9 @@ You can use the Azure portal to deploy your Function module to an IoT Edge devic
220218

221219
## View the generated data
222220

223-
You can see all of the messages that arrive at your IoT hub by running **Azure IoT Hub: Start Monitoring Built-in Event Endpoint** in the command palette.
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.
224222

225-
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 and select **Start Monitoring Built-in Event Endpoint**.
226-
227-
To stop monitoring messages, run the command **Azure IoT Hub: Stop Monitoring Built-in Event Endpoint** in the command palette.
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**.
228224

229225
## Clean up resources
230226

0 commit comments

Comments
 (0)