Skip to content

Commit 741dc2f

Browse files
authored
Merge pull request #223501 from dominicbetts/central-transparent
IoT Central: Update transparent gateway
2 parents 23844db + 112a6a4 commit 741dc2f

File tree

4 files changed

+13
-108
lines changed

4 files changed

+13
-108
lines changed

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

Lines changed: 13 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
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. The article shows how to use both the IoT Edge 1.1 and 1.2 runtimes.
2+
title: Connect an IoT Edge transparent gateway to an application
3+
description: How to connect devices through an IoT Edge transparent gateway to an IoT Central application. The article shows how to use the IoT Edge 1.4 runtime.
4+
titleSuffix: Azure IoT Central
45
author: dominicbetts
56
ms.author: dobett
6-
ms.date: 10/11/2022
7+
ms.date: 01/10/2023
78
ms.topic: how-to
89
ms.service: iot-central
910
services: iot-central
@@ -16,28 +17,14 @@ An IoT Edge device can act as a gateway that provides a connection between other
1617

1718
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:
1819

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+
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/edge-transparent-gateway.png" alt-text="Diagram that shows IoT Edge as a transparent gateway." border="false":::
2021

2122
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.
2223

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+
This article shows how to implement the scenario by using the IoT Edge 1.4 runtime.
2425

2526
## Prerequisites
2627

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/main/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)
4128
To complete the steps in this article, you need:
4229

4330
- 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.
@@ -47,9 +34,7 @@ To complete the steps in this article, you need:
4734
To follow the steps in this article, download the following files to your computer:
4835

4936
- [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.
50-
- [Transparent gateway manifest (EdgeTransparentGatewayManifest.json)](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-2/EdgeTransparentGatewayManifest.json) - this file is the IoT Edge deployment manifest for the gateway device.
51-
52-
---
37+
- [Transparent gateway manifest (EdgeTransparentGatewayManifest.json)](https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-4/EdgeTransparentGatewayManifest.json) - this file is the IoT Edge deployment manifest for the gateway device.
5338

5439
## Import deployment manifest
5540

@@ -137,109 +122,29 @@ To find these values, navigate to each device in the device list and select **Co
137122
To let you try out this scenario, the following steps show you how to deploy the gateway and downstream devices to Azure virtual machines.
138123

139124
> [!TIP]
140-
> 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.
125+
> 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.
141126
142-
# [IoT Edge 1.1](#tab/edge1-1)
127+
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.4 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:
143128

144-
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:
145-
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)
129+
[![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-4%2FDeployGatewayVMs.json)
147130

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

150133
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**.
151134

152135
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**:
153136

154-
:::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":::
137+
:::image type="content" source="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-4.png" alt-text="Screenshot showing the $edgeAgent and $edgeHub version 1.4 modules running on the IoT Edge gateway." lightbox="media/how-to-connect-iot-edge-transparent-gateway/iot-edge-runtime-1-4.png":::
155138

156139
> [!TIP]
157140
> You may have to wait for several minutes while the virtual machine starts up and the device is provisioned in your IoT Central application.
158141
159-
# [IoT Edge 1.2](#tab/edge1-2)
160-
161-
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:
162-
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)
164-
165-
When the two virtual machines are deployed and running, verify the IoT Edge gateway device is running on the `edgegateway` virtual machine:
166-
167-
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**.
168-
169-
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**:
170-
171-
:::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":::
172-
173-
> [!TIP]
174-
> You may have to wait for several minutes while the virtual machine starts up and the device is provisioned in your IoT Central application.
175-
176-
---
177-
178142
## Configure the gateway
179143

180144
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.
181145

182146
To generate the demo certificates and install them on your gateway device:
183147

184-
# [IoT Edge 1.1](#tab/edge1-1)
185-
186-
1. Use SSH to connect to and sign in on your gateway device virtual machine.
187-
188-
1. Run the following commands to clone the IoT Edge repository and generate your demo certificates:
189-
190-
```bash
191-
# Clone the repo
192-
cd ~
193-
git clone https://github.com/Azure/iotedge.git
194-
195-
# Generate the demo certificates
196-
mkdir certs
197-
cd certs
198-
cp ~/iotedge/tools/CACertificates/*.cnf .
199-
cp ~/iotedge/tools/CACertificates/certGen.sh .
200-
./certGen.sh create_root_and_intermediate
201-
./certGen.sh create_edge_device_ca_certificate "mycacert"
202-
```
203-
204-
After you run the previous commands, the following files are ready to use in the next steps:
205-
206-
- *~/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.
207-
- *~/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.
208-
- *~/certs/private/iot-edge-device-mycacert.key.pem* - The private key associated with the device CA certificate.
209-
210-
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).
211-
212-
1. Open the *config.yaml* file in a text editor. For example:
213-
214-
```bash
215-
sudo nano /etc/iotedge/config.yaml
216-
```
217-
218-
1. Locate the `Certificate settings` settings. Uncomment and modify the certificate settings as follows:
219-
220-
```text
221-
certificates:
222-
device_ca_cert: "file:///home/AzureUser/certs/certs/iot-edge-device-ca-mycacert-full-chain.cert.pem"
223-
device_ca_pk: "file:///home/AzureUser/certs/private/iot-edge-device-ca-mycacert.key.pem"
224-
trusted_ca_certs: "file:///home/AzureUser/certs/certs/azure-iot-test-only.root.ca.cert.pem"
225-
```
226-
227-
The example shown above assumes you're signed in as **AzureUser** and created a device CA certificate called "mycacert".
228-
229-
1. Save the changes and restart the IoT Edge runtime:
230-
231-
```bash
232-
sudo systemctl restart iotedge
233-
```
234-
235-
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.
236-
237-
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).
238-
239-
Your transparent gateway is now configured and ready to start forwarding telemetry from downstream devices.
240-
241-
# [IoT Edge 1.2](#tab/edge1-2)
242-
243148
1. Use SSH to connect to and sign in on your gateway device virtual machine.
244149

245150
1. Run the following commands to clone the IoT Edge repository and generate your demo certificates:
@@ -311,7 +216,7 @@ IoT Central relies on the Device Provisioning Service (DPS) to provision devices
311216
1. Run the following command to download the Python script that does the device provisioning:
312217

313218
```bash
314-
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-1/provision_device.py
219+
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-4/provision_device.py
315220
```
316221

317222
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:
@@ -345,7 +250,7 @@ To run the thermostat simulator on the `leafdevice` virtual machine:
345250

346251
```bash
347252
cd ~
348-
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-1/simple_thermostat.py
253+
wget https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/transparent-gateway-1-4/simple_thermostat.py
349254
```
350255

351256
1. Install the Azure IoT device Python module:
62.4 KB
Loading

0 commit comments

Comments
 (0)