Skip to content

Commit 1474bd5

Browse files
authored
Merge pull request #215234 from dominicbetts/central-edge-tutorial
IoT Central: add IoT Edge tutorial
2 parents adc29ad + b7e4833 commit 1474bd5

11 files changed

+233
-13
lines changed

articles/iot-central/TOC.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
items:
2626
- name: Create and connect a device
2727
href: core/tutorial-connect-device.md
28-
- name: Create a gateway device template
29-
href: core/tutorial-define-gateway-device-type.md
30-
- name: Connect an IoT Edge device
31-
href: /training/modules/connect-iot-edge-device-to-iot-central
3228
- name: Create a device group
3329
href: core/tutorial-use-device-groups.md
30+
- name: Connect an IoT Edge device
31+
href: core/tutorial-connect-iot-edge-device.md
32+
- name: Create a gateway device template
33+
href: core/tutorial-define-gateway-device-type.md
3434
- name: Extend your application
3535
items:
3636
- name: Create a rule

articles/iot-central/core/how-to-connect-iot-edge-transparent-gateway.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ To let you try out this scenario, the following steps show you how to deploy the
143143

144144
To try out the transparent gateway scenario, select the following button to deploy two Linux virtual machines. One virtual machine has the IoT Edge 1.1 runtime installed and is the transparent IoT Edge gateway. The other virtual machine is a downstream device where you run code to send simulated thermostat telemetry:
145145

146-
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmaster%2Ftransparent-gateway-1-1%2FDeployGatewayVMs.json)
146+
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmain%2Ftransparent-gateway-1-1%2FDeployGatewayVMs.json)
147147

148148
When the two virtual machines are deployed and running, verify the IoT Edge gateway device is running on the `edgegateway` virtual machine:
149149

@@ -160,7 +160,7 @@ When the two virtual machines are deployed and running, verify the IoT Edge gate
160160

161161
To try out the transparent gateway scenario, select the following button to deploy two Linux virtual machines. One virtual machine has the IoT Edge 1.2 runtime installed and is the transparent IoT Edge gateway. The other virtual machine is a downstream device where you run code to send simulated thermostat telemetry:
162162

163-
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmaster%2Ftransparent-gateway-1-2%2FDeployGatewayVMs.json)
163+
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmain%2Ftransparent-gateway-1-2%2FDeployGatewayVMs.json)
164164

165165
When the two virtual machines are deployed and running, verify the IoT Edge gateway device is running on the `edgegateway` virtual machine:
166166

articles/iot-central/core/howto-transform-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ For convenience, this article uses Azure virtual machines to run the gateway and
258258
| Authentication Type | Password |
259259
| Admin Password Or Key | Your choice of password for the **AzureUser** account on both virtual machines. |
260260
261-
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmaster%2Ftransparent-gateway-1-1%2FDeployGatewayVMs.json)
261+
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmain%2Ftransparent-gateway-1-1%2FDeployGatewayVMs.json)
262262
263263
Select **Review + Create**, and then **Create**. It takes a couple of minutes to create the virtual machines in the **ingress-scenario** resource group.
264264
32.3 KB
Loading
51.1 KB
Loading
37.8 KB
Loading
64.8 KB
Loading

articles/iot-central/core/tutorial-connect-device.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ On this view, you can select the columns to display and set a time range to view
9090
If you'd prefer to continue through the set of IoT Central tutorials and learn more about building an IoT Central solution, see:
9191

9292
> [!div class="nextstepaction"]
93-
> [Create a gateway device template](./tutorial-define-gateway-device-type.md)
93+
> [Tutorial: Use device groups to analyze device telemetry](tutorial-use-device-groups.md)
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
title: Tutorial - Connect an IoT Edge device to Azure IoT Central | Microsoft Docs
3+
description: This tutorial shows you how to connect an IoT Edge device to your IoT Central application. You first create an unassigned device, and then add a device template to enable views and forms for an operator to be able to interact with the device.
4+
author: dominicbetts
5+
ms.author: dobett
6+
ms.date: 10/18/2022
7+
ms.topic: tutorial
8+
ms.service: iot-central
9+
services: iot-central
10+
ms.custom: [device-developer]
11+
12+
# Customer intent: As a solution developer, I want to learn how to connect an IoT Edge device to IoT Central and then configure views and forms so that I can interact with the device.
13+
---
14+
15+
# Tutorial: Connect an IoT Edge device to your Azure IoT Central application
16+
17+
This tutorial shows you how to connect an IoT Edge device to your Azure IoT Central application. The IoT Edge device runs a module that sends temperature, pressure, and humidity telemetry to your application. You use a device template to enable views and forms that let you interact with the module on the IoT Edge device.
18+
19+
In this tutorial, you learn how to:
20+
21+
> [!div class="checklist"]
22+
> * Import an IoT Edge deployment manifest into your IoT Central application.
23+
> * Add an IoT Edge device that uses this deployment manifest to your application.
24+
> * Connect the IoT Edge device to your application.
25+
> * Monitor the IoT Edge runtime from your application.
26+
> * Add a device template with views and forms to your application.
27+
> * View the telemetry sent from the device in your application.
28+
29+
## Prerequisites
30+
31+
To complete the steps in this tutorial, you need:
32+
33+
[!INCLUDE [iot-central-prerequisites-basic](../../../includes/iot-central-prerequisites-basic.md)]
34+
35+
You also need to be able to upload configuration files to your IoT Central application from your local machine.
36+
37+
## Import a deployment manifest
38+
39+
A deployment manifest specifies the configuration of an IoT Edge device including the details of any custom modules the device should download and run. IoT Edge devices that connect to an IoT Central application download their deployment manifests from the application.
40+
41+
To add a deployment manifest to IoT Central to use in this tutorial:
42+
43+
1. Download and save the [EnvironmentalSensorManifest-1-4.json](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/iotedge/EnvironmentalSensorManifest-1-4.json) deployment manifest to your local machine.
44+
45+
1. In your IoT Central application, navigate to the **Edge manifests** page.
46+
47+
1. Select **+ New**.
48+
49+
1. On the **Customize** page, enter *Environmental Sensor* as the name and then upload the *EnvironmentalSensorManifest-1-4.json* file.
50+
51+
1. After the manifest file is validated, select **Next**.
52+
53+
1. The **Review and finish** page shows the modules defined in the manifest, including the **SimulatedTemperatureSensor** custom module. Select **Create**.
54+
55+
The **Edge manifests** list now includes the **Environmental sensor** manifest:
56+
57+
:::image type="content" source="media/tutorial-connect-iot-edge-device/deployment-manifests.png" alt-text="Screenshot that shows the Edge Manifests list in the application.":::
58+
59+
## Add an IoT Edge device
60+
61+
Before the IoT Edge device can connect to your IoT Central application, you need to add it to the list of devices and get its credentials:
62+
63+
1. In your IoT Central application, navigate to the **Devices** page.
64+
65+
1. On the **Devices** page, make sure that **All devices** is selected. Then select **+ New**.
66+
67+
1. On the **Create a new device** page:
68+
* Enter *Environmental sensor - 001* as the device name.
69+
* Enter *env-sens-001* as the device ID.
70+
* Make sure that the device template is **unassigned**.
71+
* Make sure that the device isn't simulated.
72+
* Set **Azure IoT Edge device** to **Yes**.
73+
* Select the **Environmental sensor** IoT Edge deployment manifest.
74+
75+
1. Select **Create**.
76+
77+
The list of devices on the **Devices** page now includes the **Environmental sensor - 001** device. The device status is **Registered**:
78+
79+
:::image type="content" source="media/tutorial-connect-iot-edge-device/registered-sensor-device.png" alt-text="Screenshot that shows the registered and unassigned IoT Edge device.":::
80+
81+
Before you deploy the IoT Edge device, you need the:
82+
83+
* **ID Scope** of your IoT Central application.
84+
* **Device ID** values for the gateway and downstream devices.
85+
* **Primary key** values for the gateway and downstream devices.
86+
87+
To find these values, navigate to the **Environmental sensor - 001** device from the **Devices** page and select **Connect**. Make a note of these values before you continue.
88+
89+
## Deploy the IoT Edge device
90+
91+
In this tutorial, you deploy the IoT Edge runtime to a Linux virtual machine in Azure. To deploy and configure the virtual machine, select the following button:
92+
93+
[![Deploy to Azure Button](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fiot-central-docs-samples%2Fmain%2Fedge-vm-deploy-1-4%2FedgeDeploy.json)
94+
95+
On the **Custom deployment** page, use the following values to complete the form:
96+
97+
| Setting | Value |
98+
| ------- | ----- |
99+
| `Resource group` | Create a new resource group with a name such as *MyIoTEdgeDevice_rg*. |
100+
| `Region` | Select a region close to you. |
101+
| `Dns Label Prefix` | A unique DNS prefix for your virtual machine. |
102+
| `Admin Username` | *AzureUser* |
103+
| `Admin Password` | A password of your choice to access the virtual machine. |
104+
| `Scope Id` | The ID scope you made a note of previously. |
105+
| `Device Id` | The device ID you made a note of previously. |
106+
| `Device Key` | The device key you made a note of previously. |
107+
108+
Select **Review + create** and then **Create**. Wait for the deployment to finish before you continue.
109+
110+
## Manage the IoT Edge device
111+
112+
To verify the deployment of the IoT Edge device was successful:
113+
114+
1. In your IoT Central application, navigate to the **Devices** page. Check the status of the **Environmental sensor - 001** device is **Provisioned**. You may need to wait for a few minutes while the device connects.
115+
116+
1. Navigate to the **Environmental sensor - 001** device.
117+
118+
1. On the **Modules** page, check the status of the three modules is **Running**.
119+
120+
On the **Modules** page, you can view status information about the modules and perform actions such as viewing their logs and restarting them.
121+
122+
## View raw data
123+
124+
On the **Raw data** page for the **Environmental sensor - 001** device, you can see the telemetry it's sending and the property values it's reporting.
125+
126+
At the moment, the IoT Edge device doesn't have a device template assigned, so all the data from the device is **Unmodeled**. Without a device template, there are no views or dashboards to display custom device information in the IoT Central application. However, you can use data export to forward the data to other services for analysis or storage.
127+
128+
## Add a device template
129+
130+
A deployment manifest may include definitions of properties exposed by a module. For example, the configuration in the deployment manifest for the **SimulatedTemperatureSensor** module includes the following:
131+
132+
```json
133+
"SimulatedTemperatureSensor": {
134+
"properties.desired": {
135+
"SendData": true,
136+
"SendInterval": 10
137+
}
138+
}
139+
```
140+
141+
The following steps show you how to add a device template for an IoT Edge device and the module property definitions from the deployment manifest:
142+
143+
1. In your IoT Central application, navigate to the **Device templates** page and select **+ New**.
144+
145+
1. On the **Select type** page, select **Azure IoT Edge**, and then **Next: Customize**.
146+
147+
1. On the **Customize** page, enter **Environmental sensor** as the device template name.
148+
149+
1. On the **Review** page, select **Create**.
150+
151+
1. On the **Create a model** page, select **Custom model**.
152+
153+
1. On the **Environmental sensor** page, select **Modules**, then **Import modules from manifest**.
154+
155+
1. In the **Import modules** dialog, select the **Environmental sensor** deployment manifest, then **Import**.
156+
157+
The device template now includes a module called **SimulatedTemperatureSensor**, with an interface called **management**. This interface includes definitions of the **SendData** and **SendInterval** properties from the deployment manifest.
158+
159+
A deployment manifest can only define module properties, not commands or telemetry. To add the telemetry definitions to the device template:
160+
161+
1. Download and save the [EnvironmentalSensorTelemetry.json](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/iotedge/EnvironmentalSensorTelemetry.json) interface definition to your local machine.
162+
163+
1. Navigate to the **SimulatedTemperatureSensor** module in the **Environmental sensor** device template.
164+
165+
1. Select **Add inherited interface** (you may need to select **...** to see this option). Select **Import interface**. Then import the *EnvironmentalSensorTelemetry.json* file you previously downloaded.
166+
167+
The module now includes a **telemetry** interface that defines **machine**, **ambient**, and **timeCreated** telemetry types:
168+
169+
:::image type="content" source="media/tutorial-connect-iot-edge-device/telemetry-interface.png" alt-text="Screenshot that shows the device template with the telemetry interface.":::
170+
171+
To add a view that plots telemetry from the device:
172+
173+
1. In the **Environmental sensor** device template, select **Views**.
174+
175+
1. On the **Select to add a new view** page, select **Visualizing the device**.
176+
177+
1. Enter *Environmental telemetry* as the view name.
178+
179+
1. Select **Start with devices**. Then add the following telemetry types:
180+
* **ambient/temperature**
181+
* **humidity**
182+
* **machine/temperature**
183+
* **pressure**
184+
185+
1. Select **Add tile**, then **Save**.
186+
187+
1. To publish the template, select **Publish**.
188+
189+
## View telemetry and control module
190+
191+
To view the telemetry from your device, you need to attach the device to the device template:
192+
193+
1. Navigate to the **Devices** page and select the **Environmental sensor - 001** device.
194+
195+
1. Select **Migrate**.
196+
197+
1. In the **Migrate** dialog, select the **Environmental sensor** device template, and select **Migrate**.
198+
199+
1. Navigate to the **Environmental sensor - 001** device and select the **Environmental telemetry** view.
200+
201+
1. The line chart plots the four telemetry values you selected for the view:
202+
203+
:::image type="content" source="media/tutorial-connect-iot-edge-device/environmental-telemetry-view.png" alt-text="Screenshot that shows the telemetry line charts.":::
204+
205+
1. The **Raw data** page now includes columns for the **ambient**, **machine**, and **timeCreated** telemetry values.
206+
207+
To control the module by using the properties defined in the deployment manifest, navigate to the **Environmental sensor - 001** device and select the **Manage** view.
208+
209+
IoT Central created this view automatically from the **manage** interface in the **SimulatedTemperatureSensor** module. The **Raw data** page now includes columns for the **SendData** and **SendInterval** properties.
210+
211+
## Clean up resources
212+
213+
[!INCLUDE [iot-central-clean-up-resources](../../../includes/iot-central-clean-up-resources.md)]
214+
215+
## Next steps
216+
217+
If you'd prefer to continue through the set of IoT Central tutorials and learn more about building an IoT Central solution, see:
218+
219+
> [!div class="nextstepaction"]
220+
> [Create a gateway device template](./tutorial-define-gateway-device-type.md)

articles/iot-central/core/tutorial-define-gateway-device-type.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In this tutorial, you create a **Smart Building** gateway device template. A **S
2222
As well as enabling downstream devices to communicate with your IoT Central application, a gateway device can also:
2323

2424
* Send its own telemetry, such as temperature.
25-
* Respond to writable property updates made by an operator. For example, an operator could changes the telemetry send interval.
25+
* Respond to writable property updates made by an operator. For example, an operator could change the telemetry send interval.
2626
* Respond to commands, such as rebooting the device.
2727

2828
In this tutorial, you learn how to:
@@ -163,7 +163,7 @@ To create a simulated gateway device:
163163

164164
1. Keep the generated **Device ID** and **Device name**. Make sure that the **Simulated** switch is **On**. Select **Create**.
165165

166-
To create a simulated downstream devices:
166+
To create simulated downstream devices:
167167

168168
1. On the **Devices** page, select **RS40 Occupancy Sensor** in the list of device templates.
169169

@@ -207,7 +207,7 @@ Both your simulated downstream devices are now connected to your simulated gatew
207207

208208
In the [Create and connect a client application to your Azure IoT Central application](tutorial-connect-device.md) tutorial, the sample code shows how to include the model ID from the device template in the provisioning payload the device sends.
209209

210-
When you connect a downstream device, you can modify the provisioning payload to include the the ID of the gateway device. The model ID lets IoT Central assign the device to the correct downstream device template. The gateway ID lets IoT Central establish the relationship between the downstream device and its gateway. In this case the provisioning payload the device sends looks like the following JSON:
210+
When you connect a downstream device, you can modify the provisioning payload to include the ID of the gateway device. The model ID lets IoT Central assign the device to the correct downstream device template. The gateway ID lets IoT Central establish the relationship between the downstream device and its gateway. In this case the provisioning payload the device sends looks like the following JSON:
211211

212212
```json
213213
{
@@ -329,4 +329,4 @@ In this tutorial, you learned how to:
329329
Next you can learn how to:
330330

331331
> [!div class="nextstepaction"]
332-
> [Add an Azure IoT Edge device to your Azure IoT Central application](/training/modules/connect-iot-edge-device-to-iot-central/)
332+
> [Create a rule and set up notifications in your Azure IoT Central application](tutorial-create-telemetry-rules.md)

0 commit comments

Comments
 (0)