教程:创建 IoT Edge 设备的层次结构(预览版)Tutorial: Create a hierarchy of IoT Edge devices (Preview)

在层次结构层中组织的网络之间部署 Azure IoT Edge 节点。Deploy Azure IoT Edge nodes across networks organized in hierarchical layers. 层次结构中的每一层都是一个网关设备,用于处理来自其下一层中设备的消息和请求。Each layer in a hierarchy is a gateway device that handles messages and requests from devices in the layer beneath it.

备注

此功能要求运行 Linux 容器的 Iot edge 1.2版本 版本,该版本为公共预览版。This feature requires IoT Edge version 1.2, which is in public preview, running Linux containers.

你可构建设备的层次结构,使得只有顶层可连接到云,而下层只能与相邻的南北层通信。You can structure a hierarchy of devices so that only the top layer has connectivity to the cloud, and the lower layers can only communicate with adjacent north and south layers. 大多数工业网络遵循 ISA-95 标准,而这种网络分层是其基础。This network layering is the foundation of most industrial networks, which follow the ISA-95 standard.

本教程的目的是创建一个模拟生产环境的 IoT Edge 设备的层次结构。The goal of this tutorial is to create a hierarchy of IoT Edge devices that simulates a production environment. 最后,你会通过层次结构下载容器映像,从而将模拟温度传感器模块部署到无 Internet 访问的下层设备。At the end, you will deploy the Simulated Temperature Sensor module to a lower layer device without internet access by downloading container images through the hierarchy.

为实现此目标,本教程将指导你创建 IoT Edge 设备的层次结构,将 IoT Edge 运行时容器部署到设备,并在本地配置设备。To accomplish this goal, this tutorial walks you through creating a hierarchy of IoT Edge devices, deploying IoT Edge runtime containers to your devices, and configuring your devices locally. 在本教程中,你将了解:In this tutorial, you learn how to:

  • 创建和定义 IoT Edge 设备层次结构中的关系。Create and define the relationships in a hierarchy of IoT Edge devices.
  • 在层次结构中的设备上配置 IoT Edge 运行时。Configure the IoT Edge runtime on the devices in your hierarchy.
  • 在设备层次结构中安装一致的证书。Install consistent certificates across your device hierarchy.
  • 向层次结构中的设备添加工作负载。Add workloads to the devices in your hierarchy.
  • 使用 API 代理模块,通过下层设备上的单个端口安全地路由 HTTP 流量。Use an API proxy module to securely route HTTP traffic over a single port from your lower layer devices.

在本教程中,定义了以下网络层:In this tutorial, the following network layers are defined:

  • 顶层:此层的 IoT Edge 设备可直接连接到云。Top layer: IoT Edge devices at this layer can connect directly to the cloud.

  • 下层:此层的 IoT Edge 设备无法直接连接到云。Lower layer: IoT Edge devices at this layer cannot connect directly to the cloud. 它们需要通过一个或多个中间 IoT Edge 设备来发送和接收数据。They need to go through one or more intermediary IoT Edge devices to send and receive data.

为简单起见,本教程使用双设备层次结构。This tutorial uses a two device hierarchy for simplicity. 一台设备是 topLayerDevice,表示位于层次结构顶层的设备,该设备可以直接连接到云。One device, topLayerDevice, represents a device at the top layer of the hierarchy, which can connect directly to the cloud. 此设备也称为“父设备”。This device will also be referred to as the parent device. 另一台设备是 lowerLayerDevice,表示位于层次结构下层的设备,该设备无法直接连接到云。The other device, lowerLayerDevice, represents a device at the lower layer of the hierarchy, which cannot connect directly to the cloud. 此设备也称为“子设备”。This device will also be referred to as the child device. 可添加额外的下层设备来表示生产环境。You can add additional lower layer devices to represent your production environment. 任何额外下层设备的配置都将遵循 lowerLayerDevice 的配置。The configuration of any additional lower layer devices will follow lowerLayerDevice's configuration.

先决条件Prerequisites

若要创建 IoT Edge 设备的层次结构,你将需要:To create a hierarchy of IoT Edge devices, you will need:

  • 一台具有 Internet 连接的计算机(Windows 或 Linux)。A computer (Windows or Linux) with internet connectivity.

  • 含有效订阅的 Azure 帐户。An Azure account with a valid subscription. 如果还没有 Azure 订阅,可以在开始前创建一个免费帐户If you don't have an Azure subscription, create a free account before you begin.

  • Azure 中的免费或标准层 IoT 中心A free or standard tier IoT Hub in Azure.

  • 安装了 Azure IoT 扩展 v0.10.6 或更高版本的 Azure CLI v2.3.1。Azure CLI v2.3.1 with the Azure IoT extension v0.10.6 or higher installed.

  • 两台要配置为 IoT Edge 设备的 Linux 设备。Two Linux devices to configure as IoT Edge devices. 如果没有可用设备,可以通过替换以下命令中的占位符文本并运行两次来创建两个 Azure 虚拟机:If you don't have devices available, you can create two Azure virtual machines by replacing the placeholder text in the following command and running it twice:

    az vm create \
      --resource-group <REPLACE_WITH_RESOURCE_GROUP> \
      --name <REPLACE_WITH_UNIQUE_NAMES_FOR_EACH_VM> \
      --image UbuntuLTS \
      --admin-username azureuser \
      --admin-password <REPLACE_WITH_PASSWORD>
    

还可遵循已编写脚本的适用于工业 IoT 的 Azure IoT Edge 示例来试用此方案,该示例将 Azure 虚拟机部署为预配置设备以模拟工厂环境。You can also try out this scenario by following the scripted Azure IoT Edge for Industrial IoT sample, which deploys Azure virtual machines as preconfigured devices to simulate a factory environment.

配置 IoT Edge 设备层次结构Configure your IoT Edge device hierarchy

创建 IoT Edge 设备的层次结构Create a hierarchy of IoT Edge devices

第一步是创建 IoT Edge 设备,可通过 Azure 门户或 Azure CLI 完成。The first step, creating your IoT Edge devices, can be done through the Azure portal or Azure CLI. 本教程将创建只有以下两个 IoT Edge 设备的层次结构:topLayerDevice 及其子 lowerLayerDevice 。This tutorial will create a hierarchy of two IoT Edge devices: topLayerDevice and its child lowerLayerDevice.

  1. Azure 门户中,导航到 IoT 中心。In the Azure portal, navigate to your IoT Hub.

  2. 从左窗格菜单中的“自动设备管理”下,选择“IoT Edge” 。From the menu on the left pane, under Automatic Device Management, select IoT Edge.

  3. 选择“+ 添加 IoT Edge 设备”。Select + Add an IoT Edge device. 此设备将为顶层设备,因此请输入适当的唯一设备 ID。This device will be the top layer device, so enter an appropriate unique device ID. 选择“保存”。Select Save.

  4. 再次选择“+ 添加 IoT Edge 设备”。Select + Add an IoT Edge device again. 此设备将为 Edge 下层设备,因此请输入适当的唯一设备 ID。This device will be the edge lower layer device, so enter an appropriate unique device ID.

  5. 选择“设置父设备”,从设备列表中选择顶层设备,然后选择“确定” 。Choose Set a parent device, choose your top layer device from the list of devices, and select Ok. 选择“保存”。Select Save.

    为下层设备设置父项

请记下每个 IoT Edge 设备的连接字符串。Make note of each IoT Edge device's connection string. 稍后将用到它们。They will be used later.

  1. Azure 门户中,导航到 IoT 中心的“IoT Edge”部分。In the Azure portal, navigate to the IoT Edge section of your IoT Hub.

  2. 单击设备列表中某个设备的设备 ID。Click on the device ID of one of the devices in the list of devices.

  3. 在“主连接字符串”字段上选择“复制”,并将其记录到所选位置 。Select Copy on the Primary Connection String field and record it in a place of your choice.

  4. 对所有其他设备重复此操作。Repeat for all other devices.

创建证书Create certificates

网关方案中的所有设备需要一个共享证书,目的是在它们之间建立安全连接。All devices in a gateway scenario need a shared certificate to set up secure connections between them. 使用以下步骤为此方案中的两个设备创建演示证书。Use the following steps to create demo certificates for both devices in this scenario.

若要在 Linux 设备上创建演示证书,需要克隆生成脚本并将其设置为在 bash 中本地运行。To create demo certificates on a Linux device, you need to clone the generation scripts and set them up to run locally in bash.

  1. 克隆 IoT Edge Git 存储库,其中包含用于生成演示证书的脚本。Clone the IoT Edge git repo, which contains scripts to generate demo certificates.

    git clone https://github.com/Azure/iotedge.git
    
  2. 导航到要在其中工作的目录。Navigate to the directory in which you want to work. 所有证书和密钥文件都将在此目录中创建。All certificate and key files will be created in this directory.

  3. 将克隆的 IoT Edge 存储库中的配置文件和脚本文件复制到该工作目录。Copy the config and script files from the cloned IoT Edge repo into your working directory.

    cp <path>/iotedge/tools/CACertificates/*.cnf .
    cp <path>/iotedge/tools/CACertificates/certGen.sh .
    
  4. 创建根 CA 证书和一个中间证书。Create the root CA certificate and one intermediate certificate.

    ./certGen.sh create_root_and_intermediate
    

    此脚本命令会创建多个证书和密钥文件,但我们将使用以下文件作为网关层次结构的根 CA 证书:This script command creates several certificate and key files, but we are using the following file as the root CA certificate for the gateway hierarchy:

    • <WRKDIR>/certs/azure-iot-test-only.root.ca.cert.pem
  5. 使用以下命令创建两组 IoT Edge 设备 CA 证书和私钥:一组用于顶层设备,另一组用于下层设备。Create two sets of IoT Edge device CA certificates and private keys with the following command: one set for the top layer device and one set for the lower layer device. 为 CA 证书提供易记的名称以区分它们。Provide memorable names for the CA certificates to distinguish them from each other.

    ./certGen.sh create_edge_device_ca_certificate "top-layer-device"
    ./certGen.sh create_edge_device_ca_certificate "lower-layer-device"
    

    此脚本命令会创建多个证书和密钥文件,但我们将在每个 IoT Edge 设备上使用以下证书和密钥对,并在 config.yaml 文件中引用它们:This script command creates several certificate and key files, but we are using the following certificate and key pair on each IoT Edge device and referenced in the config.yaml file:

    • <WRKDIR>/certs/iot-edge-device-<CA cert name>-full-chain.cert.pem
    • <WRKDIR>/private/iot-edge-device-<CA cert name>.key.pem

每个设备都需要根 CA 证书的副本,以及自己的设备 CA 证书和私钥的副本。Each device needs a copy of the root CA certificate and a copy of its own device CA certificate and private key. 可使用 U 盘或安全文件复制将证书移动到每个设备上。You can use a USB drive or secure file copy to move the certificates to each device.

  1. 传输证书后,为每个设备安装根 CA。After the certificates are transferred, install the root CA for each device.

    sudo cp <path>/azure-iot-test-only.root.ca.cert.pem /usr/local/share/ca-certificates/azure-iot-test-only.root.ca.cert.pem.crt
    sudo update-ca-certificates
    

    此命令应输出:已在 /etc/ssl/certs 中添加了一个证书。This command should output that one certificate has been added in /etc/ssl/certs.

在设备上安装 IoT EdgeInstall IoT Edge on the devices

在两个设备上执行以下步骤来安装 IoT Edge。Install IoT Edge by following these steps on both devices.

  1. 更新设备上的包列表。Update package lists on your device.

    sudo apt-get update
    
  2. 安装 Moby 引擎。Install the Moby engine.

    sudo apt-get install moby-engine
    
  3. 安装 hsmlib 和 IoT Edge 守护程序。Install the hsmlib and IoT Edge daemon. 要查看其他 Linux 发行版的资产,请访问 GitHub 版本To see the assets for other Linux distributions, visit the GitHub release.

    curl -L https://github.com/Azure/azure-iotedge/releases/download/1.2.0-rc1/libiothsm-std_1.2.0.rc1-1-1_debian9_amd64.deb -o libiothsm-std.deb
    curl -L https://github.com/Azure/azure-iotedge/releases/download/1.2.0-rc1/iotedge_1.2.0_rc1-1_debian9_amd64.deb -o iotedge.deb
    sudo dpkg -i ./libiothsm-std.deb
    sudo dpkg -i ./iotedge.deb
    

配置 IoT Edge 运行时Configure the IoT Edge runtime

在两个设备上执行以下步骤来配置 IoT Edge 运行时。Configure the IoT Edge runtime by following these steps on both your devices. 为设备配置 IoT Edge 运行时包含四个步骤,所有步骤均通过编辑 IoT Edge 配置文件来完成:Configuring the IoT Edge runtime for your devices consists of four steps, all accomplished by editing the IoT Edge configuration file:

  1. 通过将设备的连接字符串添加到配置文件,手动预配每个设备。Manually provision each device by adding that device's connection string to the configuration file.

  2. 通过将配置文件指向设备 CA 证书、设备 CA 私钥和根 CA 证书,完成设备证书的设置。Finish setting up your device's certificates by pointing the configuration file to the device CA certificate, device CA private key, and root CA certificate.

  3. 使用 IoT Edge 代理启动系统。Bootstrap the system using the IoT Edge agent.

  4. 更新顶层设备的 hostname 参数,并更新下层设备的 hostname 参数和 parent_hostname 参数 。Update the hostname parameter for your top layer device, and update both the hostname parameter and parent_hostname parameter for your lower layer devices.

完成这些步骤,然后重启 IoT Edge 服务来配置设备。Complete these steps and restart the IoT Edge service to configure your devices.

  1. 在每个设备上,打开 IoT Edge 配置文件。On each device, open the IoT Edge configuration file.

    sudo nano /etc/iotedge/config.yaml
    
  2. 找到文件的预配配置,并取消注释“使用连接字符串手动预配配置”部分。Find the provisioning configurations of the file and uncomment the Manual provisioning configuration using a connection string section.

  3. 使用 IoT Edge 设备的连接字符串更新 device_connection_string 的值。Update the value of device_connection_string with the connection string from your IoT Edge device. 请确保注释掉任何其他预配部分。请确保 provisioning: 行前面没有空格,并且嵌套项缩进了两个空格。Make sure any other provisioning sections are commented out. Make sure the provisioning: line has no preceding whitespace and that nested items are indented by two spaces.

    # Manual provisioning configuration using a connection string
    provisioning:
      source: "manual"
      device_connection_string: "<ADD DEVICE CONNECTION STRING HERE>"
      dynamic_reprovisioning: false
    

    提示

    将剪贴板内容粘贴到 Nano Shift+Right Click 或按 Shift+InsertTo paste clipboard contents into Nano Shift+Right Click or press Shift+Insert.

  4. 找到“证书”部分。Find the certificates section. 取消注释并更新三个证书字段,使这些字段指向你在上一节中创建并移动到 IoT Edge 设备的证书。Uncomment and update the three certificate fields to point to the certificates that you created in the previous section and moved to the IoT Edge device. 提供采用 file:///<path>/<filename> 格式的文件 URI 路径。Provide the file URI paths, which take the format file:///<path>/<filename>.

    certificates:
      device_ca_cert: "<File URI path to the device CA certificate unique to this device.>"
      device_ca_pk: "<File URI path to the device CA private key unique to this device.>"
      trusted_ca_certs: "<File URI path to the root CA certificate shared by all devices in the gateway hierarchy.>"
    
  5. 对于顶层设备,查找 hostname 参数 。For your top layer device, find the hostname parameter. 将值更新为 IoT Edge 设备的完全限定的域名 (FQDN) 或 IP 地址。Update the value to be the fully qualified domain name (FQDN) or IP address of the IoT Edge device. 在层次结构中的设备之间一致使用你选择的任何值。Use whichever value you choose consistently across the devices in your hierarchy.

    hostname: <device fqdn or IP>
    
  6. 对于下层的 IoT Edge 设备,请更新配置文件以指向父设备的 FQDN 或 IP,与父设备 hostname 字段中的内容相匹配 。For IoT Edge devices in lower layers, update the config file to point to the FQDN or IP of the parent device, matching whatever is in the parent device's hostname field. 对于顶层的 IoT Edge 设备,请注释禁止此参数。For IoT Edge devices in the top layer, leave this parameter commented out.

    parent_hostname: <parent device fqdn or IP>
    

    备注

    对于具有多个下层的层次结构,请将 parent_hostname 字段更新为直接上层设备的 FQDN。For hierarchies with more than one lower layer, update the parent_hostname field with the FQDN of the device in the layer immediately above.

  7. 对于顶层设备,查找“代理”yaml 部分,并将映像值更新为 IoT Edge 代理的正确版本 。For your top layer device, find the agent yaml section and update the image value to the correct version of the IoT Edge agent. 在本例中,我们会将顶层 IoT Edge 代理指向 Azure 容器注册表,其中提供 IoT Edge 代理映像的公共预览版。In this case, we will point the top layer's IoT Edge agent at the Azure Container Registry with the public preview version of IoT Edge agent image available.

    agent:
      name: "edgeAgent"
      type: "docker"
      env: {}
      config:
        image: "mcr.microsoft.com/azureiotedge-agent:1.2.0-rc2"
        auth: {}
    
  8. 对于下层的 IoT Edge 设备,请更新映像值的域名以指向父设备的 FQDN 或 IP,后跟 API 代理端口 8000。For IoT Edge devices in lower layers, update the image value's domain name to point to the parent device's FQDN or IP followed by the API proxy port, 8000. 你将在下一节中添加 API 代理模块。You will add the API proxy module in the next section.

    agent:
      name: "edgeAgent"
      type: "docker"
      env: {}
      config:
        image: "<parent_device_fqdn_or_ip>:8000/azureiotedge-agent:1.2.0-rc2"
        auth: {}
    
  9. 保存并关闭该文件。Save and close the file.

    CTRL + X, Y, EnterCTRL + X, Y, Enter

  10. 在配置文件中输入预配信息后,重启守护程序:After entering the provisioning information in the configuration file, restart the daemon:

    sudo systemctl restart iotedge
    

将模块部署到顶层设备Deploy modules to the top layer device

可通过 Azure 门户或 Azure CLI,在云中完成 IoT Edge 运行时的配置和部署工作负载的剩余步骤。The remaining steps to complete the configuration of the IoT Edge runtime and deploy workloads are done from the Cloud either via the Azure portal or Azure CLI.

Azure 门户中:In the Azure portal:

  1. 导航到 IoT 中心。Navigate to your IoT Hub.

  2. 从左窗格菜单中的“自动设备管理”下,选择“IoT Edge” 。From the menu on the left pane, under Automatic Device Management, select IoT Edge.

  3. 在设备列表中单击顶层 Edge 设备的设备 ID。Click on the device ID of your top layer edge device in the list of devices.

  4. 在上方栏中,选择“设置模块”。On the upper bar, select Set Modules.

  5. 选择齿轮图标旁边的“运行时设置”。Select Runtime Settings, next to the gear icon.

  6. 在“Edge 中心”下的映像字段中输入 mcr.microsoft.com/azureiotedge-hub:1.2.0-rc2Under Edge Hub, in the image field, enter mcr.microsoft.com/azureiotedge-hub:1.2.0-rc2.

    编辑 Edge 中心的映像

  7. 将以下环境变量添加到 Edge 中心模块:Add the following environment variables to your Edge Hub module:

    名称Name Value
    experimentalFeatures__enabled true
    experimentalFeatures__nestedEdgeEnabled true

    编辑 Edge 中心的环境变量

  8. 在“Edge 代理”下的映像字段中输入 mcr.microsoft.com/azureiotedge-agent:1.2.0-rc2Under Edge Agent, in the image field, enter mcr.microsoft.com/azureiotedge-agent:1.2.0-rc2. 选择“保存”。Select Save.

  9. 将 Docker 注册表模块添加到顶层设备。Add the Docker registry module to your top layer device. 选择“+ 添加”,然后从下拉列表中选择“IoT Edge 模块” 。Select + Add and choose IoT Edge Module from the dropdown. 为 Docker 注册表模块提供名称 registry,并为映像 URI 输入 registry:latestProvide the name registry for your Docker registry module and enter registry:latest for the image URI. 接下来,添加环境变量并创建选项,以将本地注册表模块指向 Microsoft 容器注册表,以便从中下载容器映像并在 registry:5000 中提供这些映像。Next, add environment variables and create options to point your local registry module at the Microsoft container registry to download container images from and to serve these images at registry:5000.

  10. 在“环境变量”选项卡下,输入以下环境变量名称/值对:Under the environment variables tab, enter the following environment variable name-value pair:

    名称Name Value
    REGISTRY_PROXY_REMOTEURL https://mcr.microsoft.com
  11. 在“容器创建选项”选项卡下,输入以下 JSON:Under the container create options tab, enter the following JSON:

    {
     "HostConfig": {
         "PortBindings": {
             "5000/tcp": [
                 {
                     "HostPort": "5000"
                 }
             ]
          }
       }
    }
    
  12. 接下来,将 API 代理模块添加到顶层设备。Next, add the API proxy module to your top layer device. 选择“+ 添加”,然后从下拉列表中选择“市场模块” 。Select + Add and choose Marketplace Module from the dropdown. 搜索 IoT Edge API Proxy 并选择该模块。Search for IoT Edge API Proxy and select the module. 默认情况下,IoT Edge API 代理使用端口 8000,并被配置为使用端口 5000 上名为 registry 的注册表模块。The IoT Edge API proxy uses port 8000 and is configured to use your registry module named registry on port 5000 by default.

  13. 依次选择“查看 + 创建”和“创建”来完成部署 。Select Review + create, then Create to complete the deployment. 顶层设备的 IoT Edge 运行时(可访问 Internet)将拉取并运行 IoT Edge 中心和 IoT Edge 代理的公共预览版配置。Your top layer device's IoT Edge runtime, which has access to the internet, will pull and run the public preview configs for IoT Edge hub and IoT Edge agent.

    包含 Edge 中心、Edge 代理、注册表模块和 API 代理模块的完整部署

将模块部署到下层设备Deploy modules to the lower layer device

可使用 Azure 门户和 Azure CLI 将工作负载从云部署到下层设备。You can use both the Azure portal and Azure CLI to deploy workloads from the Cloud to your lower layer devices.

Azure 门户中:In the Azure portal:

  1. 导航到 IoT 中心。Navigate to your IoT Hub.

  2. 从左窗格菜单中的“自动设备管理”下,选择“IoT Edge” 。From the menu on the left pane, under Automatic Device Management, select IoT Edge.

  3. 在 IoT Edge 设备列表中单击下层设备的设备 ID。Click on the device ID of your lower layer device in the list of IoT Edge devices.

  4. 在上方栏中,选择“设置模块”。On the upper bar, select Set Modules.

  5. 选择齿轮图标旁边的“运行时设置”。Select Runtime Settings, next to the gear icon.

  6. 在“Edge 中心”下的映像字段中输入 $upstream:8000/azureiotedge-hub:1.2.0-rc2Under Edge Hub, in the image field, enter $upstream:8000/azureiotedge-hub:1.2.0-rc2.

  7. 将以下环境变量添加到 Edge 中心模块:Add the following environment variables to your Edge Hub module:

    名称Name Value
    experimentalFeatures__enabled true
    experimentalFeatures__nestedEdgeEnabled true
  8. 在“Edge 代理”下的映像字段中输入 $upstream:8000/azureiotedge-agent:1.2.0-rc2Under Edge Agent, in the image field, enter $upstream:8000/azureiotedge-agent:1.2.0-rc2. 选择“保存”。Select Save.

  9. 添加温度传感器模块。Add the temperature sensor module. 选择“+ 添加”,然后从下拉列表中选择“市场模块” 。Select + Add and choose Marketplace Module from the dropdown. 搜索 Simulated Temperature Sensor 并选择该模块。Search for Simulated Temperature Sensor and select the module.

  10. 在“IoT Edge 模块”下,选择刚添加的 Simulated Temperature Sensor 模块,并更新其映像 URI 以指向 $upstream:8000/azureiotedge-simulated-temperature-sensor:1.0Under IoT Edge Modules, select the Simulated Temperature Sensor module you just added and update its image URI to point to $upstream:8000/azureiotedge-simulated-temperature-sensor:1.0.

  11. 依次选择“保存”、“查看 + 创建”和“创建”来完成部署 。Select Save, Review + create, and Create to complete the deployment.

    包含 Edge 中心、边缘代理和模拟温度传感器的完整部署

Notice that the image URI that we used for the simulated temperature sensor module pointed to $upstream:8000 instead of to a container registry. We configured this device to not have direct connections to the cloud, because it's in a lower layer. To pull container images, this device requests the image from its parent device instead. At the top layer, the API proxy module routes this container request to the registry module, which handles the image pull.

On the device details page for your lower layer IoT Edge device, you should now see the temperature sensor module listed along the system modules as Specified in deployment. It may take a few minutes for the device to receive its new deployment, request the container image, and start the module. Refresh the page until you see the temperature sensor module listed as Reported by device.

View generated data

The Simulated Temperature Sensor module that you pushed generates sample environment data. It sends messages that include ambient temperature and humidity, machine temperature and pressure, and a timestamp.

You can watch the messages arrive at your IoT hub by using the Azure IoT Hub extension for Visual Studio Code.

You can also view these messages through the Azure CLI:

az iot hub monitor-events -n <iothub_name> -d <lower-layer-device-name>

清理资源Clean up resources

可以删除本文中创建的本地配置和 Azure 资源,以避免收费。You can delete the local configurations and the Azure resources that you created in this article to avoid charges.

若要删除资源,请执行以下操作:To delete the resources:

  1. 登录到 Azure 门户,然后选择“资源组”。 Sign in to the Azure portal and select Resource groups.

  2. 选择包含 IoT Edge 测试资源的资源组的名称。Select the name of the resource group that contains your IoT Edge test resources.

  3. 查看包含在资源组中的资源的列表。Review the list of resources contained in your resource group. 若要删除这一切,可以选择“删除资源组”。If you want to delete all of them, you can select Delete resource group. 如果只需删除部分内容,可以单击要单独删除的每个资源。If you want to delete only some of them, you can click into each resource to delete them individually.

后续步骤Next steps

在本教程中,你已将两个 IoT Edge 设备配置为网关,并设置了一个作为另一个设备的父设备。In this tutorial, you configured two IoT Edge devices as gateways and set one as the parent device of the other. 然后,演示了如何通过网关将容器映像拉取到子设备上。Then, you demonstrated pulling a container image onto the child device through a gateway.