在 Windows 设备上安装和预配 Azure IoT Edge for Linux(预览版)Install and provision Azure IoT Edge for Linux on a Windows device (Preview)

使用 Azure IoT Edge 运行时可将设备转变为 IoT Edge 设备。The Azure IoT Edge runtime is what turns a device into an IoT Edge device. 此运行时可以部署在小到电脑大到工业服务器的设备上。The runtime can be deployed on devices from PC class to industrial servers. 使用 IoT Edge 运行时配置设备后,即可开始从云中部署业务逻辑。Once a device is configured with the IoT Edge runtime, you can start deploying business logic to it from the cloud. 若要了解详细信息,请参阅了解 Azure IoT Edge 运行时及其体系结构To learn more, see Understand the Azure IoT Edge runtime and its architecture.

Azure IoT Edge for Linux on Windows 允许你通过 Linux 虚拟机在 Windows 设备上使用 Azure IoT Edge。Azure IoT Edge for Linux on Windows allows you to use Azure IoT Edge on Windows devices by using Linux virtual machines. Linux 版本的 Azure IoT Edge 和随它部署的任何 Linux 模块都在虚拟机上运行。The Linux version of Azure IoT Edge and any Linux modules deployed with it run on the virtual machine. 在虚拟机中,Windows 应用程序和代码以及 IoT Edge 运行时和模块可以自由地彼此交互。From there, Windows applications and code and the IoT Edge runtime and modules can freely interact with each other.

本文列出了在 Windows 设备上设置 IoT Edge 的步骤。This article lists the steps to set up IoT Edge on a Windows device. 这些步骤将部署一台 Linux 虚拟机(其中包含要在 Windows 设备上运行的 IoT Edge 运行时),然后为设备预配其 IoT 中心设备标识。These steps deploy a Linux virtual machine that contains the IoT Edge runtime to run on your Windows device, then provision the device with its IoT Hub device identity.

备注

IoT Edge for Linux on Windows 现提供公共预览版IoT Edge for Linux on Windows is in public preview.

虽然在 Windows 环境中使用 Azure IoT Edge 时建议使用 IoT Edge for Linux on Windows,但仍可使用 Windows 容器。While IoT Edge for Linux on Windows is the recommended experience for using Azure IoT Edge in a Windows environment, Windows containers are still available. 如果更喜欢使用 Windows 容器,请参阅有关安装和管理适用于 Windows 的 Azure IoT Edge 的操作指南。If you prefer to use Windows containers, see the how-to guide on installing and managing Azure IoT Edge for Windows.

先决条件Prerequisites

  • 含有效订阅的 Azure 帐户。An Azure account with a valid subscription. 如果没有 Azure 订阅,请在开始之前创建试用版If you don't have an Azure subscription, create a Trial before you begin.

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

  • 一台满足以下最低系统要求的 Windows 设备:A Windows device with the following minimum system requirements:

    • Windows 10 版本 1809 或更高版本;内部版本 17763 或更高版本Windows 10 Version 1809 or later; build 17763 or later
    • Professional、Enterprise 或 Server 版Professional, Enterprise, or Server editions
    • 最小 RAM:4 GB(建议 8 GB)Minimum RAM: 4 GB (8 GB recommended)
    • 最小存储:10 GBMinimum Storage: 10 GB
  • 能够访问安装了适用于 Windows Admin Center 的 Azure IoT Edge 扩展的 Windows Admin Center 预览体验内部版本: Access to Windows Admin Center insider build with the Azure IoT Edge extension for Windows Admin Center installed:

    1. 访问 Windows 预览体验预览版Visit the Windows Insider Preview.

    2. 在“预览版”下拉列表中,选择“Windows Admin Center 预览版 - 内部版本 2012”,然后选择“确认”。In the previews dropdown, select Windows Admin Center Preview - Build 2012, and choose Confirm.

      从可用预览版的下拉菜单中选择“Windows Admin Center 预览版 - 内部版本 2012”。

    3. 在“选择语言”下拉列表中选择“英语”,然后选择“确认”。In the Select Language dropdown, choose English, and choose Confirm.

    4. 选择“立即下载”以下载“WindowsAdminCenterPreview2012.msi”。Choose Download Now to download the WindowsAdminCenterPreview2012.msi.

    5. 运行“WindowsAdminCenterPreview2012.msi”并按照安装向导提示安装 Windows Admin Center。Run the WindowsAdminCenterPreview2012.msi and follow the install wizard prompts to install Windows Admin Center. 在安装后,打开 Windows Admin Center。Once installed, open Windows Admin Center.

    6. 当你第一次使用 Windows Admin Center 时,系统会提示你选择要使用的证书。On the first use of Windows Admin Center, you will be prompted to select a certificate to use. 请选择“Windows Admin Center 客户端”作为你的证书。Select Windows Admin Center Client as your certificate.

    7. 接下来应该安装 Azure IoT Edge 扩展。It is time to install the Azure IoT Edge extension. 选择 Windows Admin Center 仪表板右上方的齿轮图标。Select the gear icon in the top right of the Windows Admin Center dashboard.

      选择仪表板右上方的齿轮图标以访问设置。

    8. 在“设置”菜单上的“网关”下,选择“扩展”。 On the Settings menu, under Gateway, select Extensions.

    9. 选择“源”选项卡,然后选择“添加” 。Select the Feeds tab and select Add.

    10. 在文本框中输入 https://aka.ms/wac-insiders-feed ,然后选择“添加”。Enter https://aka.ms/wac-insiders-feed into the text box and select Add.

    11. 添加源后,导航到“可用扩展”选项卡。系统可能需要一段时间来更新扩展列表。After the feed has been added, navigate to the Available extensions tab. It may take a moment to update the extensions list.

    12. 在“可用扩展”选项卡上的扩展列表中找到“Azure IoT Edge”。On the Available extensions tab, find Azure IoT Edge in the list of extensions. 选择它,然后选择扩展列表上方的“安装”提示。Choose it, and select the Install prompt above the list of extensions.

    13. 安装完成后,你应该会在“已安装的扩展”选项卡上的已安装扩展列表中看到 Azure IoT Edge。After the installation completes, you should see Azure IoT Edge in the list of installed extensions on the Installed extensions tab.

选择预配方法Choose your provisioning method

Azure IoT Edge for Linux on Windows 支持以下预配方法:Azure IoT Edge for Linux on Windows supports the following provisioning methods:

如果一开始只使用少量设备,则手动预配更为容易。Manual provisioning is easier to get started with a few devices. 如果要预配许多设备,则可使用设备预配服务。The Device Provisioning Service is helpful for provisioning many devices.

如果你计划使用 DPS 方法之一来预配你的设备,请按照上面链接的合适文章中的步骤创建一个 DPS 实例,将你的 DPS 实例链接到 IoT 中心,然后创建一个 DPS 注册。If you plan on using one of the DPS methods to provision your device or devices, follow the steps in the appropriate article linked above to create an instance of DPS, link your DPS instance to your IoT Hub, and create a DPS enrollment. 你可以为单个设备创建单个注册,也可以为一组设备创建组注册。You can create an individual enrollment for a single device or a group enrollment for a group of devices. 有关注册类型的详细信息,请访问 Azure IoT 中心设备预配服务概念For more information about the enrollment types, visit the Azure IoT Hub Device Provisioning Service concepts.

创建新部署Create a new deployment

在目标设备上创建你的 Azure IoT Edge for Linux on Windows 部署。Create your deployment of Azure IoT Edge for Linux on Windows on your target device.

在 Windows Admin Center 起始页的连接列表下,你会看到一个本地主机连接,该连接表示运行 Windows Admin Center 的电脑。On the Windows Admin Center start page, under the list of connections, you will see a local host connection representing the PC where you running Windows Admin Center. 你管理的任何其他服务器、电脑或群集也会显示在此处。Any additional servers, PCs, or clusters that you manage will also show up here.

你可以使用 Windows Admin Center 在本地设备或远程的受管理设备上安装和管理 Azure IoT Edge for Linux on Windows。You can use Windows Admin Center to make install and manage Azure IoT Edge for Linux on Windows on either your local device or remote managed devices. 在本指南中,本地主机连接将充当用于部署 Azure IoT Edge for Linux on Windows 的目标设备。In this guide, the local host connection will serve as the target device for the deployment of Azure IoT Edge for Linux on Windows.

如果你要部署到远程目标设备而非本地设备,但在列表中看不到所需的目标设备,请按照设备添加说明进行操作。If you want to deploy to a remote target device instead of your local device and you do not see your desired target device in the list, follow the instructions to add your device..

列出了目标设备的初始 Windows Admin Center 仪表板

  1. 选择 添加Select Add.

  2. 在“添加或创建资源”窗格中,找到“Azure IoT Edge”磁贴。On the Add or create resources pane, locate the Azure IoT Edge tile. 选择“新建”,以在设备上安装 Azure IoT Edge for Linux on Windows 的新实例。Select Create new to install a new instance of Azure IoT Edge for Linux on Windows on a device.

    如果你有已在设备上运行的 IoT Edge for Linux on Windows,则可选择“添加”以连接到该现有的 IoT Edge 设备,并使用 Windows Admin Center 对其进行管理。If you already have IoT Edge for Linux on Windows running on a device, you could select Add to connect to that existing IoT Edge device and manage it with Windows Admin Center.

    在 Windows Admin Center 中的 Azure IoT Edge 磁贴上选择“新建”

  3. “创建 Azure IoT Edge for Linux on Windows 部署”窗格将会打开。The Create an Azure IoT Edge for Linux on Windows deployment pane will open. 在“1.开始使用”选项卡上,验证你的目标设备是否满足最低要求,然后选择“下一步”。On the 1. Getting Started tab, verify that your target device meets the minimum requirements, and select Next.

  4. 查看许可条款,选中“我接受”,然后选择“下一步”。Review the license terms, check I Accept, and select Next.

  5. 你可以根据自己的偏好,打开或关闭“可选诊断数据”。You can toggle Optional diagnostic data on or off, depending on your preference.

  6. 在完成时选择“下一步:部署Select Next: Deploy.

    在根据你的偏好设置可选诊断数据选项后,选择“下一步:部署”按钮。

  7. 在“2.部署”选项卡上的“选择目标设备”下,单击你的已列出设备以验证它是否满足最低要求。On the 2. Deploy tab, under Select a target device, click on your listed device to validate it meets the minimum requirements. 在确认其状态为“受支持”后,选择“下一步”。Once its status is confirmed as supported, select Next.

    选择你的设备以验证它是否受支持

  8. 接受“2.2 设置”选项卡上的默认设置。Accept the default settings on the 2.2 Settings tab.

  9. 在“2.3 部署”选项卡上,你可以观察部署进度。On the 2.3 Deployment tab, you can watch the progress of the deployment. 完整的过程包括下载 Azure IoT Edge for Linux on Windows 程序包,安装该程序包,配置主机设备以及设置 Linux 虚拟机。The full process includes downloading the Azure IoT Edge for Linux on Windows package, installing the package, configuring the host device, and setting up the Linux virtual machine. 此过程可能需要几分钟才能完成。This process may take several minutes to complete. 下面描绘了一个成功的部署。A successful deployment is pictured below.

    成功的部署所显示的每个步骤都会带有绿色的复选标记和“完成”标签

部署完成后,便可预配设备了。Once your deployment is complete, you are ready to provision your device. 选择“下一步:连接”以转到“3.连接”选项卡,可以在这里处理 Azure IoT Edge 设备预配。Select Next: Connect to proceed to the 3. Connect tab, which handles Azure IoT Edge device provisioning.

若要预配你的设备,可以访问下面的链接以跳转到你选择的预配方法对应的部分:To provision your device, you can follow the links below to jump to the section for your selected provisioning method:

预配你的设备Provision your device

选择一种用于预配你的设备的方法,并按照相应部分中的说明进行操作。Choose a method for provisioning your device and follow the instructions in the appropriate section. 你可以使用 Windows Admin Center 或已提升权限的 PowerShell 会话来预配你的设备。You can use the Windows Admin Center or an elevated PowerShell session to provision your devices.

选项 1:使用连接字符串进行手动预配Option 1: Provisioning manually using the connection string

本部分介绍了如何使用 Azure IoT Edge 设备的连接字符串手动预配你的设备。This section covers provisioning your device manually using your Azure IoT Edge device's connection string.

  1. 在“Azure IoT Edge 设备预配”窗格上,从“预配方法”下拉列表中选择“连接字符串(手动)”。On the Azure IoT Edge device provisioning pane, select Connection String (Manual) from the provisioning method dropdown.

  2. Azure 门户中,导航到 IoT 中心的“IoT Edge”选项卡。In the Azure portal, navigate to the IoT Edge tab of your IoT Hub.

  3. 单击设备的设备 ID。Click on the device ID of your device. 复制“主连接字符串”字段。Copy the Primary Connection String field.

  4. 将其粘贴到 Windows Admin Center 中的“设备连接字符串”字段。Paste it into the device connection string field in the Windows Admin Center. 然后,选择“使用所选方法进行预配”。Then, choose Provisioning with the selected method.

    粘贴设备的连接字符串后,选择“使用所选方法进行预配”

  5. 预配完成后,选择“完成”。Once the provisioning is complete, select Finish. 将返回到主仪表板。You will be taken back to the main dashboard. 现在,你应该会看到一个列出的新设备,其类型为“IoT Edge Devices”。Now, you should see a new device listed, whose type is IoT Edge Devices. 你可以选择该 IoT Edge 设备以连接到它。You can select the IoT Edge device to connect to it. 在“概述”页上以后,即可查看设备的“IoT Edge 模块列表”和“IoT Edge 状态”。Once on its Overview page, you can view the IoT Edge Module List and IoT Edge Status of your device.

选项 2:通过 DPS 使用对称密钥进行预配Option 2: Provisioning via DPS using symmetric keys

本部分介绍了如何使用 DPS 和对称密钥自动预配你的设备。This section covers provisioning your device automatically using DPS and symmetric keys.

  1. 在“Azure IoT Edge 设备预配”窗格上,从“预配方法”下拉列表中选择“对称密钥(DPS)”。On the Azure IoT Edge device provisioning pane, select Symmetric Key (DPS) from the provisioning method dropdown.

  2. Azure 门户中,导航到你的 DPS 实例。In the Azure portal, navigate to your DPS instance.

  3. 在“概述”选项卡上,复制“ID 作用域”值。On the Overview tab, copy the ID Scope value. 将其粘贴到 Windows Admin Center 中的“作用域 ID”字段。Paste it into the scope ID field in the Windows Admin Center.

  4. 在 Azure 门户中的“管理注册”选项卡上,选择你创建的注册。On the Manage enrollments tab in the Azure portal, select the enrollment you created. 复制注册详细信息中的“主密钥”值。Copy the Primary Key value in the enrollment details. 将其粘贴到 Windows Admin Center 的“对称密钥”字段中。Paste it into the symmetric key field in the Windows Admin Center.

  5. 在 Windows Admin Center 的“注册 ID”字段中提供设备的注册 ID。Provide the registration ID of your device in the registration ID field in the Windows Admin Center.

  6. 选择“使用所选方法进行预配”。Choose Provisioning with the selected method.

    填写对称密钥预配的必填字段后,选择“使用所选方法进行预配”。

  7. 预配完成后,选择“完成”。Once the provisioning is complete, select Finish. 将返回到主仪表板。You will be taken back to the main dashboard. 现在,你应该会看到一个列出的新设备,其类型为“IoT Edge Devices”。Now, you should see a new device listed, whose type is IoT Edge Devices. 你可以选择该 IoT Edge 设备以连接到它。You can select the IoT Edge device to connect to it. 在“概述”页上以后,即可查看设备的“IoT Edge 模块列表”和“IoT Edge 状态”。Once on its Overview page, you can view the IoT Edge Module List and IoT Edge Status of your device.

选项 3:通过 DPS 使用 X.509 证书进行预配Option 3: Provisioning via DPS using X.509 certificates

本部分介绍了如何使用 DPS 和 X.509 证书自动预配你的设备。This section covers provisioning your device automatically using DPS and X.509 certificates.

  1. 在“Azure IoT Edge 设备预配”窗格上,从“预配方法”下拉列表中选择“X.509 证书(DPS)”。On the Azure IoT Edge device provisioning pane, select X.509 Certificate (DPS) from the provisioning method dropdown.

  2. Azure 门户中,导航到你的 DPS 实例。In the Azure portal, navigate to your DPS instance.

  3. 在“概述”选项卡上,复制“ID 作用域”值。On the Overview tab, copy the ID Scope value. 将其粘贴到 Windows Admin Center 中的“作用域 ID”字段。Paste it into the scope ID field in the Windows Admin Center.

  4. 在 Windows Admin Center 的“注册 ID”字段中提供设备的注册 ID。Provide the registration ID of your device in the registration ID field in the Windows Admin Center.

  5. 上传你的证书和私钥文件。Upload your certificate and private key files.

  6. 选择“使用所选方法进行预配”。Choose Provisioning with the selected method.

    填写 X.509 证书预配的必填字段后,选择“使用所选方法进行预配”。

  7. 预配完成后,选择“完成”。Once the provisioning is complete, select Finish. 将返回到主仪表板。You will be taken back to the main dashboard. 现在,你应该会看到一个列出的新设备,其类型为“IoT Edge Devices”。Now, you should see a new device listed, whose type is IoT Edge Devices. 你可以选择该 IoT Edge 设备以连接到它。You can select the IoT Edge device to connect to it. 在“概述”页上以后,即可查看设备的“IoT Edge 模块列表”和“IoT Edge 状态”。Once on its Overview page, you can view the IoT Edge Module List and IoT Edge Status of your device.

验证成功的配置Verify successful configuration

验证是否已在 IoT Edge 设备上成功安装并配置了 IoT Edge for Linux on Windows。Verify that IoT Edge for Linux on Windows was successfully installed and configured on your IoT Edge device.

  1. 从 Windows Admin Center 中所连接设备的列表中选择你的 IoT Edge 设备,以连接到该设备。Select your IoT Edge device from the list of connected devices in Windows Admin Center to connect to it.

  2. 设备概述页会显示有关设备的一些信息:The device overview page displays some information about the device:

    1. “IoT Edge 模块列表”部分会显示设备上正在运行的模块。The IoT Edge Module List section shows running modules on the device. 当 IoT Edge 服务首次启动时,你应当只会看到 edgeAgent 模块正在运行。When the IoT Edge service starts for the first time, you should only see the edgeAgent module running. edgeAgent 模块会默认运行,用于安装并启动部署到设备的任何其他模块。The edgeAgent module runs by default and helps to install and start any additional modules that you deploy to your device.
    2. “IoT Edge 状态”部分会显示服务状态,并且应当报告“活动(正在运行)”。The IoT Edge Status section shows the service status, and should be reporting active (running).
  3. 如果需要对 IoT Edge 服务进行故障排除,请使用设备页上的“命令外壳”工具通过 ssh(安全外壳)连接到虚拟机,并运行 Linux 命令。If you need to troubleshoot the IoT Edge service, use the Command Shell tool on the device page to ssh (secure shell) into the virtual machine and run the Linux commands.

    1. 若需排查服务问题,请检索服务日志。If you need to troubleshoot the service, retrieve the service logs.

      journalctl -u iotedge
      
    2. 使用 check 工具验证设备的配置和连接状态。Use the check tool to verify configuration and connection status of the device.

      sudo iotedge check
      

后续步骤Next steps

转到部署 IoT Edge 模块,了解如何将模块部署到设备上。Continue to deploy IoT Edge modules to learn how to deploy modules onto your device.