Skip to content

Commit 13f1862

Browse files
committed
Add IoT Edge 1.2 instructions
1 parent d552d6a commit 13f1862

File tree

6 files changed

+120
-15
lines changed

6 files changed

+120
-15
lines changed

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

Lines changed: 120 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Connect an IoT Edge transparent gateway to an Azure IoT Central application
3-
description: How to connect devices through an IoT Edge transparent gateway to an IoT Central application
3+
description: How to connect devices through an IoT Edge transparent gateway to an IoT Central application. The article shows how to use both the IoT Edge 1.1 and 1.2 runtimes.
44
author: dominicbetts
55
ms.author: dobett
6-
ms.date: 02/28/2022
6+
ms.date: 05/08/2022
77
ms.topic: how-to
88
ms.service: iot-central
99
services: iot-central
@@ -14,14 +14,30 @@ ms.custom: device-developer
1414

1515
An IoT Edge device can act as a gateway that provides a connection between other devices on a local network and your IoT Central application. You use a gateway when the device can't access your IoT Central application directly.
1616

17-
IoT Edge supports the [*transparent* and *translation* gateway patterns](../../iot-edge/iot-edge-as-gateway.md). This article summarizes how to implement the transparent gateway pattern. In this pattern, the gateway passes messages from the downstream device through to the IoT Hub endpoint in your IoT Central application. The gateway does not manipulate the messages as they pass through. In IoT Central, each downstream device appears as child to the gateway device:
17+
IoT Edge supports the [*transparent* and *translation* gateway patterns](../../iot-edge/iot-edge-as-gateway.md). This article summarizes how to implement the transparent gateway pattern. In this pattern, the gateway passes messages from the downstream device through to the IoT Hub endpoint in your IoT Central application. The gateway doesn't manipulate the messages as they pass through. In IoT Central, each downstream device appears as child to the gateway device:
1818

1919
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/edge-transparent-gateway.png" alt-text="IoT Edge as a transparent gateway." border="false":::
2020

2121
For simplicity, this article uses virtual machines to host the downstream and gateway devices. In a real scenario, the downstream device and gateway would run on physical devices on your local network.
2222

23+
This article shows how to implement the scenario by using either the IoT Edge 1.1 runtime or the IoT Edge 1.2 runtime.
24+
2325
## Prerequisites
2426

27+
# [IoT Edge 1.1](#tab/edge1-1)
28+
29+
To complete the steps in this article, you need:
30+
31+
- An active Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
32+
33+
- An [IoT Central application created](howto-create-iot-central-application.md) from the **Custom application** template. To learn more, see [Create an IoT Central application](howto-create-iot-central-application.md).
34+
35+
To follow the steps in this article, download the following files to your computer:
36+
37+
- [Thermostat device model (thermostat-1.json)](https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main/dtmi/com/example/thermostat-1.json) - this file is the device model for the downstream devices.
38+
- [Transparent gateway manifest (EdgeTransparentGatewayManifest.json)](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway-1-1/EdgeTransparentGatewayManifest.json) - this file is the IoT Edge deployment manifest for the gateway device.
39+
40+
# [IoT Edge 1.2](#tab/edge1-2)
2541
To complete the steps in this article, you need:
2642

2743
- An active Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
@@ -31,7 +47,9 @@ To complete the steps in this article, you need:
3147
To follow the steps in this article, download the following files to your computer:
3248

3349
- [Thermostat device model (thermostat-1.json)](https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main/dtmi/com/example/thermostat-1.json) - this file is the device model for the downstream devices.
34-
- [Transparent gateway manifest (EdgeTransparentGatewayManifest.json)](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway/EdgeTransparentGatewayManifest.json) - this file is the IoT Edge deployment manifest for the gateway device.
50+
- [Transparent gateway manifest (EdgeTransparentGatewayManifest.json)](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway-1-2/EdgeTransparentGatewayManifest.json) - this file is the IoT Edge deployment manifest for the gateway device.
51+
52+
---
3553

3654
## Add device templates
3755

@@ -107,29 +125,52 @@ To find these values, navigate to each device in the device list and select **Co
107125
To let you try out this scenario, the following steps show you how to deploy the gateway and downstream devices to Azure virtual machines.
108126

109127
> [!TIP]
110-
> To learn how to deploy the IoT Edge runtime to a physical device, see [Create an IoT Edge device](../../iot-edge/how-to-create-iot-edge-device.md) in the IoT Edge documentation.
128+
> To learn how to deploy the IoT Edge 1.1 or 1.2 runtime to a physical device, see [Create an IoT Edge device](../../iot-edge/how-to-create-iot-edge-device.md) in the IoT Edge documentation.
129+
130+
# [IoT Edge 1.1](#tab/edge1-1)
131+
132+
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:
133+
134+
[![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)
135+
136+
When the two virtual machines are deployed and running, verify the IoT Edge gateway device is running on the `edgegateway` virtual machine:
137+
138+
1. Go to the **Devices** page in your IoT Central application. If the IoT Edge gateway device is connected to IoT Central, its status is **Provisioned**.
139+
140+
1. Open the IoT Edge gateway device and verify the status of the modules on the **Modules** page. If the IoT Edge runtime started successfully, the status of the **$edgeAgent** and **$edgeHub** modules is **Running**:
141+
142+
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-1.png" alt-text="Screenshot showing the $edgeAgent and $edgeHub version 1.1 modules running on the IoT Edge gateway." lightbox="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-1.png":::
143+
144+
> [!TIP]
145+
> You may have to wait for several minutes while the virtual machine starts up and the device is provisioned in your IoT Central application.
146+
147+
# [IoT Edge 1.2](#tab/edge1-2)
111148

112-
To try out the transparent gateway scenario, select the following button to deploy two Linux virtual machines. One virtual machine has the IoT Edge runtime installed and is the transparent IoT Edge gateway. The other virtual machine is a downstream device where you'll run code to send simulated thermostat telemetry:
149+
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:
113150

114-
[![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%2FDeployGatewayVMs.json)
151+
[![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)
115152

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

118155
1. Go to the **Devices** page in your IoT Central application. If the IoT Edge gateway device is connected to IoT Central, its status is **Provisioned**.
119156

120157
1. Open the IoT Edge gateway device and verify the status of the modules on the **Modules** page. If the IoT Edge runtime started successfully, the status of the **$edgeAgent** and **$edgeHub** modules is **Running**:
121158

122-
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime.png" alt-text="Screenshot showing the $edgeAgent and $edgeHub modules running on the IoT Edge gateway." lightbox="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime.png":::
159+
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-2.png" alt-text="Screenshot showing the $edgeAgent and $edgeHub version 1.2 modules running on the IoT Edge gateway." lightbox="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-2.png":::
123160

124161
> [!TIP]
125162
> You may have to wait for several minutes while the virtual machine starts up and the device is provisioned in your IoT Central application.
126163
164+
---
165+
127166
## Configure the gateway
128167

129168
For your IoT Edge device to function as a transparent gateway, it needs some certificates to prove its identity to any downstream devices. This article uses demo certificates. In a production environment, use certificates from your certificate authority.
130169

131170
To generate the demo certificates and install them on your gateway device:
132171

172+
# [IoT Edge 1.1](#tab/edge1-1)
173+
133174
1. Use SSH to connect to and sign in on your gateway device virtual machine.
134175

135176
1. Run the following commands to clone the IoT Edge repository and generate your demo certificates:
@@ -138,7 +179,7 @@ To generate the demo certificates and install them on your gateway device:
138179
# Clone the repo
139180
cd ~
140181
git clone https://github.com/Azure/iotedge.git
141-
182+
142183
# Generate the demo certificates
143184
mkdir certs
144185
cd certs
@@ -151,7 +192,7 @@ To generate the demo certificates and install them on your gateway device:
151192
After you run the previous commands, the following files are ready to use in the next steps:
152193

153194
- *~/certs/certs/azure-iot-test-only.root.ca.cert.pem* - The root CA certificate used to make all the other demo certificates for testing an IoT Edge scenario.
154-
- *~/certs/certs/iot-edge-device-mycacert-full-chain.cert.pem* - A device CA certificate that's referenced from the *config.yaml* file. In a gateway scenario, this CA certificate is how the IoT Edge device verifies its identity to downstream devices.
195+
- *~/certs/certs/iot-edge-device-mycacert-full-chain.cert.pem* - A device CA certificate that's referenced from the IoT Edge configuration file. In a gateway scenario, this CA certificate is how the IoT Edge device verifies its identity to downstream devices.
155196
- *~/certs/private/iot-edge-device-mycacert.key.pem* - The private key associated with the device CA certificate.
156197
157198
To learn more about these demo certificates, see [Create demo certificates to test IoT Edge device features](../../iot-edge/how-to-create-test-certificates.md).
@@ -171,7 +212,7 @@ To generate the demo certificates and install them on your gateway device:
171212
trusted_ca_certs: "file:///home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem"
172213
```
173214
174-
The example shown above assumes you're signed in as **AzureUser** and created a device CA certificated called "mycacert".
215+
The example shown above assumes you're signed in as **AzureUser** and created a device CA certificate called "mycacert".
175216

176217
1. Save the changes and restart the IoT Edge runtime:
177218

@@ -181,10 +222,70 @@ To generate the demo certificates and install them on your gateway device:
181222

182223
If the IoT Edge runtime starts successfully after your changes, the status of the **$edgeAgent** and **$edgeHub** modules changes to **Running** on the **Modules** page for your gateway device in IoT Central.
183224

184-
If the runtime doesn't start, check the changes you made in *config.yaml* and see [Troubleshoot your IoT Edge device](../../iot-edge/troubleshoot.md).
225+
If the runtime doesn't start, check the changes you made in the IoT Edge configuration file and see [Troubleshoot your IoT Edge device](../../iot-edge/troubleshoot.md).
226+
227+
Your transparent gateway is now configured and ready to start forwarding telemetry from downstream devices.
228+
229+
# [IoT Edge 1.2](#tab/edge1-2)
230+
231+
1. Use SSH to connect to and sign in on your gateway device virtual machine.
232+
233+
1. Run the following commands to clone the IoT Edge repository and generate your demo certificates:
234+
235+
```bash
236+
# Clone the repo
237+
cd ~
238+
git clone https://github.com/Azure/iotedge.git
239+
240+
# Generate the demo certificates
241+
mkdir certs
242+
cd certs
243+
cp ~/iotedge/tools/CACertificates/*.cnf .
244+
cp ~/iotedge/tools/CACertificates/certGen.sh .
245+
./certGen.sh create_root_and_intermediate
246+
./certGen.sh create_edge_device_ca_certificate "mycacert"
247+
```
248+
249+
After you run the previous commands, the following files are ready to use in the next steps:
250+
251+
- *~/certs/certs/azure-iot-test-only.root.ca.cert.pem* - The root CA certificate used to make all the other demo certificates for testing an IoT Edge scenario.
252+
- *~/certs/certs/iot-edge-device-mycacert-full-chain.cert.pem* - A device CA certificate that's referenced from the IoT Edge configuration file. In a gateway scenario, this CA certificate is how the IoT Edge device verifies its identity to downstream devices.
253+
- *~/certs/private/iot-edge-device-mycacert.key.pem* - The private key associated with the device CA certificate.
254+
255+
To learn more about these demo certificates, see [Create demo certificates to test IoT Edge device features](../../iot-edge/how-to-create-test-certificates.md).
256+
257+
1. Open the *config.toml* file in a text editor. For example:
258+
259+
```bash
260+
sudo nano /etc/aziot/config.toml
261+
```
262+
263+
1. Locate the `Certificate settings` settings. Add the certificate settings as follows:
264+
265+
```text
266+
trust_bundle_cert = "file:///home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem"
267+
268+
[edge_ca]
269+
cert = "file:///home/AzureUser/certs/certs/iot-edge-device-ca-mycacert-full-chain.cert.pem"
270+
pk = "file:///home/AzureUser/certs/private/iot-edge-device-ca-mycacert.key.pem"
271+
```
272+
273+
The example shown above assumes you're signed in as **AzureUser** and created a device CA certificate called "mycacert".
274+
275+
1. Save the changes and restart the IoT Edge runtime:
276+
277+
```bash
278+
sudo iotedge config apply
279+
```
280+
281+
If the IoT Edge runtime starts successfully after your changes, the status of the **$edgeAgent** and **$edgeHub** modules changes to **Running** on the **Modules** page for your gateway device in IoT Central.
282+
283+
If the runtime doesn't start, check the changes you made in the IoT Edge configuration file and see [Troubleshoot your IoT Edge device](../../iot-edge/troubleshoot.md).
185284

186285
Your transparent gateway is now configured and ready to start forwarding telemetry from downstream devices.
187286

287+
---
288+
188289
## Provision a downstream device
189290

190291
IoT Central relies on the Device Provisioning Service (DPS) to provision devices in IoT Central. Currently, IoT Edge can't use DPS provision a downstream device to your IoT Central application. The following steps show you how to provision the `thermostat1` device manually. To complete these steps, you need an environment with Python 3.6 (or higher) installed and internet connectivity. The [Azure Cloud Shell](https://shell.azure.com/) has Python 3.7 pre-installed:
@@ -198,7 +299,7 @@ IoT Central relies on the Device Provisioning Service (DPS) to provision devices
198299
1. Run the following command to download the Python script that does the device provisioning:
199300
200301
```bash
201-
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway/provision_device.py
302+
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway-1-1/provision_device.py
202303
```
203304
204305
1. To provision the `thermostat1` downstream device in your IoT Central application, run the following commands, replacing `{your application id scope}` and `{your device primary key}`. You made a note of these values when you added the devices to your IoT Central application:
@@ -216,7 +317,11 @@ In your IoT Central application, verify that the **Device status** for the `ther
216317
217318
In the previous section, you configured the `edgegateway` virtual machine with the demo certificates to enable it to run as gateway. The `leafdevice` virtual machine is ready for you to install a thermostat simulator that uses the gateway to connect to IoT Central.
218319
219-
The `leafdevice` virtual machine needs a copy of the root CA certificate you created on the `edgegateway` virtual machine. Copy the */home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem* file from the `edgegateway` virtual machine to your home directory on the `leafdevice` virtual machine. You can use the **scp** command to copy files between Linux virtual machines.
320+
The `leafdevice` virtual machine needs a copy of the root CA certificate you created on the `edgegateway` virtual machine. Copy the */home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem* file from the `edgegateway` virtual machine to your home directory on the `leafdevice` virtual machine. You can use the **scp** command to copy files between Linux virtual machines. For example, from the `leafdevice` machine:
321+
322+
```bash
323+
scp AzureUser@edgegateway:/home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem .
324+
```
220325
221326
To learn how to check the connection from the downstream device to the gateway, see [Test the gateway connection](../../iot-edge/how-to-connect-downstream-device.md#test-the-gateway-connection).
222327
@@ -228,7 +333,7 @@ To run the thermostat simulator on the `leafdevice` virtual machine:
228333
229334
```bash
230335
cd ~
231-
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway/simple_thermostat.py
336+
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/master/transparent-gateway-1-1/simple_thermostat.py
232337
```
233338
234339
1. Install the Azure IoT device Python module:
-100 KB
Loading
-78.6 KB
Loading
-102 KB
Loading
52.1 KB
Loading

0 commit comments

Comments
 (0)