Skip to content

Commit a428f72

Browse files
authored
Merge pull request #231775 from w-azure/winona-deploy-function
Adjusted some images
2 parents f50d001 + 7ceac23 commit a428f72

File tree

2 files changed

+25
-31
lines changed

2 files changed

+25
-31
lines changed
8.66 KB
Loading

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

Lines changed: 25 additions & 31 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
@@ -25,26 +25,24 @@ You can use Azure Functions to deploy code that implements your business logic d
2525
> * Deploy the module from the container registry to your IoT Edge device.
2626
> * View filtered data.
2727
28-
<center>
29-
![Diagram - Tutorial architecture: stage and deploy function module](./media/tutorial-deploy-function/functions-architecture.png)
30-
</center>
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.":::
3129

3230
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.
3331

3432
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
3533

3634
## Prerequisites
3735

38-
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:
3937

4038
* A free or standard-tier [IoT Hub](../iot-hub/iot-hub-create-through-portal.md) in Azure.
41-
* 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).
4240
* A container registry, like [Azure Container Registry](../container-registry/index.yml).
4341
* [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
4442
[Azure IoT Hub](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) extensions.
4543
* Download and install a [Docker compatible container management system](support.md#container-engines) on your development machine. Configure it to run Linux containers.
4644

47-
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:
4846

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

5654
### Create a new project
5755

58-
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.
5957

6058
1. Open Visual Studio Code on your development machine.
6159

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

64-
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:
6563

66-
| Field | Value |
67-
| ----- | ----- |
68-
| Select folder | Choose the location on your development machine for Visual Studio Code to create the solution files. |
69-
| Provide a solution name | Enter a descriptive name for your solution, like **FunctionSolution**, or accept the default. |
70-
| Select module template | Choose **Azure Functions - C#**. |
71-
| Provide a module name | Name your module **CSharpFunction**. |
72-
| 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.
7369

74-
![Provide Docker image repository](./media/tutorial-deploy-function/repository.png)
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.":::
7571

7672
### Add your registry credentials
7773

78-
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.
7975

80-
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:
8177

82-
1. In the Visual Studio Code explorer, open the .env file.
83-
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.
8480
3. Save this file.
8581

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

9187
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.
9288

93-
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**.
9490

9591
2. In the command palette, select the AMD64 target architecture from the list of options.
9692

9793
### Update the module with custom code
9894

99-
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.
10096

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

10399
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.
104100

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

202198
1. In the Azure portal, browse to your Azure container registry.
203-
2. Select **Repositories**.
199+
2. Select **Services** > **Repositories**.
204200
3. You should see the **csharpfunction** repository in the list. Select this repository to see more details.
205201
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.
206202

207203
## Deploy and run the solution
208204

209-
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.
210206

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

@@ -218,15 +214,13 @@ You can use the Azure portal to deploy your Function module to an IoT Edge devic
218214

219215
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.
220216

221-
![View deployed modules in Visual Studio Code](./media/tutorial-deploy-function/view-modules.png)
217+
:::image type="content" source="./media/tutorial-deploy-function/view-modules.png" alt-text="Screenshot showing how to view deployed modules in Visual Studio Code.":::
222218

223219
## View the generated data
224220

225-
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.
226222

227-
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**.
228-
229-
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**.
230224

231225
## Clean up resources
232226

0 commit comments

Comments
 (0)