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
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.
4
4
author: dominicbetts
5
5
ms.author: dobett
6
-
ms.date: 02/28/2022
6
+
ms.date: 05/08/2022
7
7
ms.topic: how-to
8
8
ms.service: iot-central
9
9
services: iot-central
@@ -14,14 +14,30 @@ ms.custom: device-developer
14
14
15
15
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.
16
16
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:
18
18
19
19
:::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":::
20
20
21
21
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.
22
22
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
+
23
25
## Prerequisites
24
26
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)
25
41
To complete the steps in this article, you need:
26
42
27
43
- 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:
31
47
To follow the steps in this article, download the following files to your computer:
32
48
33
49
-[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
+
---
35
53
36
54
## Add device templates
37
55
@@ -107,29 +125,52 @@ To find these values, navigate to each device in the device list and select **Co
107
125
To let you try out this scenario, the following steps show you how to deploy the gateway and downstream devices to Azure virtual machines.
108
126
109
127
> [!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
+
[](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)
111
148
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:
113
150
114
-
[](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
+
[](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)
115
152
116
153
When the two virtual machines are deployed and running, verify the IoT Edge gateway device is running on the `edgegateway` virtual machine:
117
154
118
155
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**.
119
156
120
157
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**:
121
158
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":::
123
160
124
161
> [!TIP]
125
162
> You may have to wait for several minutes while the virtual machine starts up and the device is provisioned in your IoT Central application.
126
163
164
+
---
165
+
127
166
## Configure the gateway
128
167
129
168
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.
130
169
131
170
To generate the demo certificates and install them on your gateway device:
132
171
172
+
# [IoT Edge 1.1](#tab/edge1-1)
173
+
133
174
1. Use SSH to connect to and sign in on your gateway device virtual machine.
134
175
135
176
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:
138
179
# Clone the repo
139
180
cd~
140
181
git clone https://github.com/Azure/iotedge.git
141
-
182
+
142
183
# Generate the demo certificates
143
184
mkdir certs
144
185
cd certs
@@ -151,7 +192,7 @@ To generate the demo certificates and install them on your gateway device:
151
192
After you run the previous commands, the following files are ready to use in the next steps:
152
193
153
194
- *~/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.
155
196
- *~/certs/private/iot-edge-device-mycacert.key.pem* - The private key associated with the device CA certificate.
156
197
157
198
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:
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".
175
216
176
217
1. Save the changes and restart the IoT Edge runtime:
177
218
@@ -181,10 +222,70 @@ To generate the demo certificates and install them on your gateway device:
181
222
182
223
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 foryour gateway devicein IoT Central.
183
224
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:
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:
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).
185
284
186
285
Your transparent gateway is now configured and ready to start forwarding telemetry from downstream devices.
187
286
287
+
---
288
+
188
289
## Provision a downstream device
189
290
190
291
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
198
299
1. Run the following command to download the Python script that does the device provisioning:
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
216
317
217
318
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.
218
319
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:
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).
222
327
@@ -228,7 +333,7 @@ To run the thermostat simulator on the `leafdevice` virtual machine:
0 commit comments