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/tutorial-deploy-function.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,34 +25,34 @@ You can use Azure Functions to deploy code that implements your business logic d
25
25
26
26
<center>
27
27
28
-

28
+

29
29
</center>
30
30
31
31
>[!NOTE]
32
-
>Azure Function modules on Azure IoT Edge are in [public preview](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
32
+
>Azure Function modules on Azure IoT Edge are in [public preview](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
33
33
34
-
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.
34
+
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.
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 for Linux devices](tutorial-develop-for-linux.md). By completing that tutorial, you should have the following prerequisites in place:
40
+
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 for Linux devices](tutorial-develop-for-linux.md). By completing that tutorial, you should have the following prerequisites in place:
41
41
42
42
* A free or standard-tier [IoT Hub](../iot-hub/iot-hub-create-through-portal.md) in Azure.
43
43
* A [Linux device running Azure IoT Edge](quickstart-linux.md)
44
44
* A container registry, like [Azure Container Registry](https://docs.microsoft.com/azure/container-registry/).
45
45
*[Visual Studio Code](https://code.visualstudio.com/) configured with the [Azure IoT Tools](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools).
46
46
*[Docker CE](https://docs.docker.com/install/) configured to run Linux containers.
47
47
48
-
To develop an IoT Edge module in with Azure Functions, install the following additional prerequisites on your development machine:
48
+
To develop an IoT Edge module in with Azure Functions, install the following additional prerequisites on your development machine:
49
49
50
50
*[C# for Visual Studio Code (powered by OmniSharp) extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp).
The Azure IoT Tools for Visual Studio Code that you installed in the prerequisites provides management capabilities as well as some code templates. In this section, you use Visual Studio Code to create an IoT Edge solution that contains an Azure function.
55
+
The Azure IoT Tools for Visual Studio Code that you installed in the prerequisites provides management capabilities as well as some code templates. In this section, you use Visual Studio Code to create an IoT Edge solution that contains an Azure function.
56
56
57
57
### Create a new project
58
58
@@ -84,11 +84,11 @@ The environment file stores the credentials for your container registry and shar
84
84
85
85
### Select your target architecture
86
86
87
-
Currently, Visual Studio Code can develop C modules for Linux AMD64 and Linux ARM32v7 devices. You need to select which architecture you're targeting with each solution, because the container is built and run differently for each architecture type. The default is Linux AMD64.
87
+
Currently, Visual Studio Code can develop C modules for Linux AMD64 and Linux ARM32v7 devices. You need to select which architecture you're targeting with each solution, because the container is built and run differently for each architecture type. The default is Linux AMD64.
88
88
89
-
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**, or select the shortcut icon in the side bar at the bottom of the window.
90
90
91
-
2. In the command palette, select the target architecture from the list of options. For this tutorial, we're using an Ubuntu virtual machine as the IoT Edge device, so will keep the default **amd64**.
91
+
2. In the command palette, select the target architecture from the list of options. For this tutorial, we're using an Ubuntu virtual machine as the IoT Edge device, so will keep the default **amd64**.
92
92
93
93
### Update the module with custom code
94
94
@@ -141,7 +141,7 @@ Let's add some additional code so that the module processes the messages at the
logger.LogInformation("Info: Received and transferred a message with temperature above the threshold");
147
147
}
@@ -173,11 +173,11 @@ Let's add some additional code so that the module processes the messages at the
173
173
174
174
## Build your IoT Edge solution
175
175
176
-
In the previous section, you created an IoT Edge solution and added code to the **CSharpFunction** to filter out messages where the reported machine temperature is less than the acceptable threshold. Now you need to build the solution as a container image and push it to your container registry.
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.
177
177
178
178
In this section, you provide the credentials for your container registry for the second time (the first was in the **.env** file of your IoT Edge solution) by signing in locally from your development machine so that Visual Studio Code can push images to your registry.
179
179
180
-
1. Open the VS Code integrated terminal by selecting **View** > **Terminal**.
180
+
1. Open the VS Code integrated terminal by selecting **View** > **Terminal**.
181
181
182
182
2. Sign in to your container registry by entering the following command in the integrated terminal. Use the username and login server that you copied from your Azure container registry earlier.
183
183
@@ -192,52 +192,52 @@ In this section, you provide the credentials for your container registry for the
192
192
Login Succeeded
193
193
```
194
194
195
-
3. In the VS Code explorer, right-click the deployment.template.json file and select **Build and Push IoT Edge solution**.
195
+
3. In the VS Code explorer, right-click the deployment.template.json file and select **Build and Push IoT Edge solution**.
196
196
197
-
When you tell Visual Studio Code to build your solution, it first takes the information in the deployment template and generates a deployment.json file in a new folder named **config**. Then it runs two commands in the integrated terminal: `docker build` and `docker push`. These two commands build your code, containerize the functions, and then push the code to the container registry that you specified when you initialized the solution.
197
+
When you tell Visual Studio Code to build your solution, it first takes the information in the deployment template and generates a deployment.json file in a new folder named **config**. Then it runs two commands in the integrated terminal: `docker build` and `docker push`. The build command builds your code and containerizes the functions. Then, the push command pushes the code to the container registry that you specified when you initialized the solution.
198
198
199
199
## View your container image
200
200
201
-
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.
201
+
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.
202
202
203
-
1. In the Azure portal, browse to your Azure container registry.
203
+
1. In the Azure portal, browse to your Azure container registry.
204
204
2. Select **Repositories**.
205
205
3. You should see the **csharpfunction** repository in the list. Select this repository to see more details.
206
-
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.
206
+
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.
207
207
208
208
## Deploy and run the solution
209
209
210
-
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 Tools for VS Code that was listed in the prerequisites. Install the extension now, if you didn't already.
210
+
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 Tools for VS Code that was listed in the prerequisites. Install the extension now, if you didn't already.
211
211
212
-
1. In the VS Code explorer, expand the **Azure IoT Hub Devices** section.
212
+
1. In the VS Code explorer, expand the **Azure IoT Hub Devices** section.
213
213
214
-
2. Right-click the name of your IoT Edge device, and then select **Create Deployment for single device**.
214
+
2. Right-click the name of your IoT Edge device, and then select **Create Deployment for single device**.
215
215
216
216
3. Browse to the solution folder that contains the **CSharpFunction**. Open the config folder, select the **deployment.json** file, and then choose **Select Edge Deployment Manifest**.
217
217
218
-
4. Refresh the **Azure IoT Hub Devices** section. You should see the new **CSharpFunction** running along with the **SimulatedTemperatureSensor** module and the **$edgeAgent** and **$edgeHub**. 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.
218
+
4. Refresh the **Azure IoT Hub Devices** section. You should see the new **CSharpFunction** running along with the **SimulatedTemperatureSensor** module and the **$edgeAgent** and **$edgeHub**. 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.
219
219
220
220

221
221
222
-
## View generated data
222
+
## View the generated data
223
223
224
224
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.
225
225
226
226
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**.
227
227
228
-
To stop monitoring messages, run the command **Azure IoT Hub: Stop Monitoring Built-in Event Endpoint** in the command palette.
228
+
To stop monitoring messages, run the command **Azure IoT Hub: Stop Monitoring Built-in Event Endpoint** in the command palette.
229
229
230
230
## Clean up resources
231
231
232
-
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.
232
+
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.
233
233
234
-
Otherwise, you can delete the local configurations and the Azure resources that you created in this article to avoid charges.
234
+
Otherwise, you can delete the local configurations and the Azure resources that you created in this article to avoid charges.
In this tutorial, you created an Azure function module with code to filter raw data that's generated by your IoT Edge device. When you're ready to build your own modules, you can learn more about how to [Develop with Azure IoT Edge for Visual Studio Code](how-to-vs-code-develop-module.md).
240
+
In this tutorial, you created an Azure function module with code to filter raw data that's generated by your IoT Edge device. When you're ready to build your own modules, you can learn more about how to [Develop with Azure IoT Edge for Visual Studio Code](how-to-vs-code-develop-module.md).
241
241
242
242
Continue on to the next tutorials to learn other ways that Azure IoT Edge can help you turn data into business insights at the edge.
0 commit comments