在 Windows 上安装 Azure IoT Edge 运行时Install the Azure IoT Edge runtime on Windows

使用 Azure IoT Edge 运行时可将设备转变为 IoT Edge 设备。The Azure IoT Edge runtime is what turns a device into an IoT Edge device. 该运行时可以部署在像 Raspberry Pi 一样小的设备上,也可以部署在像工业服务器一样大的设备上。The runtime can be deployed on devices as small as a Raspberry Pi or as large as an industrial server. 使用 IoT Edge 运行时配置设备后,即可开始从云中部署业务逻辑。Once a device is configured with the IoT Edge runtime, you can start deploying business logic to it from the cloud.

若要详细了解 IoT Edge 运行时,请参阅了解 Azure IoT Edge 运行时及其体系结构To learn more about the IoT Edge runtime, see Understand the Azure IoT Edge runtime and its architecture.

本文列出了使用 Windows 容器在 Windows x64 (AMD/Intel) 系统上安装 Azure IoT Edge 运行时的步骤。This article lists the steps to install the Azure IoT Edge runtime on your Windows x64 (AMD/Intel) system using Windows containers.

备注

当 IoT Edge 模块(进程隔离的 Windows Nano Server 容器)正在运行时,一个已知的 Windows 操作系统问题会阻止转换到睡眠和休眠电源状态。A known Windows operating system issue prevents transition to sleep and hibernate power states when IoT Edge modules (process-isolated Windows Nano Server containers) are running. 此问题会影响设备的电池寿命。This issue impacts battery life on the device.

作为解决方法,在使用这些电源状态之前,请使用 Stop-Service iotedge 命令停止任何正在运行的 IoT Edge 模块。As a workaround, use the command Stop-Service iotedge to stop any running IoT Edge modules before using these power states.

不推荐或支持在 Windows 系统上使用 Linux 容器作为 Azure IoT Edge 的生产配置。Using Linux containers on Windows systems is not a recommended or supported production configuration for Azure IoT Edge. 但可将其用于开发和测试。However, it can be used for development and testing purposes. 有关详细信息,请参阅使用 Windows 上的 IoT Edge 运行 Linux 容器To learn more, see Use IoT Edge on Windows to run Linux containers.

有关最新 IoT Edge 版本包含的功能的信息,请参阅 Azure IoT Edge 版本For information about what's included in the latest version of IoT Edge, see Azure IoT Edge releases.

先决条件Prerequisites

参考本部分检查你的 Windows 设备是否支持 IoT Edge,并在安装之前为容器引擎准备好该设备。Use this section to review whether your Windows device can support IoT Edge, and to prepare it for a container engine before installation.

支持的 Windows 版本Supported Windows versions

用于 Windows 的 IoT Edge 需要 Windows 版本 1809/内部版本 17763,这是最新的 Windows 长期支持版本IoT Edge for Windows requires Windows version 1809/build 17763, which is the latest Windows long term support build. 对于 Windows SKU 支持,请根据你是准备生产方案还是开发和测试方案,查看支持的内容:For Windows SKU support, see what is supported based on whether you're preparing for production scenarios or development and test scenarios:

  • 生产:有关生产方案目前支持哪些操作系统的最新信息,请参阅 Azure IoT Edge 支持的系统Production: For the latest information about which operating systems are currently supported for production scenarios, see Azure IoT Edge supported systems.
  • 开发和测试:对于开发和测试方案,包含 Windows 容器的 Azure IoT Edge 可以安装在支持容器功能的 Windows 内部版本 17763 的任何 SKU(专业版、企业版、服务器等)上。Development and test: For development and test scenarios, Azure IoT Edge with Windows containers can be installed on any SKU (Pro, Enterprise, Server etc.) of Windows build 17763 that supports the containers feature.

IoT Core 设备必须包含 IoT Core Windows 容器可选功能才能支持 IoT Edge 运行时。IoT Core devices must include the IoT Core Windows Containers optional feature to support the IoT Edge runtime. 远程 PowerShell 会话中使用以下命令来检查设备是否支持 Windows 容器:Use the following command in a remote PowerShell session to check that Windows containers are supported on your device:

Get-Service vmcompute

如果存在该服务,则应该会收到成功的响应,其中服务状态列为“正在运行”。If the service is present, you should get a successful response with the service status listed as running. 如果找不到 vmcompute 服务,则设备不满足 IoT Edge 的要求。If the vmcompute service is not found, then your device does not meet the requirements for IoT Edge. 请与硬件提供商联系,询问此功能是否支持。Contact your hardware provider to ask about support for this feature.

为容器引擎做好准备Prepare for a container engine

Azure IoT Edge 依赖于 OCI 兼容的容器引擎。Azure IoT Edge relies on a OCI-compatible container engine. 对于生产方案,请使用安装脚本中包含的 Moby 引擎在 Windows 设备上运行 Windows 容器。For production scenarios, use the Moby engine included in the installation script to run Windows containers on your Windows device.

在新设备上安装 IoT EdgeInstall IoT Edge on a new device

备注

Azure IoT Edge 软件程序包受制于程序包中的许可条款(位于 LICENSE 目录中)。Azure IoT Edge software packages are subject to the license terms located in the packages (in the LICENSE directory). 使用程序包之前请阅读这些许可条款。Please read the license terms prior to using the package. 安装和使用程序包即表示接受这些条款。Your installation and use of the package constitutes your acceptance of these terms. 如果不同意许可条款,则不要使用程序包。If you do not agree with the license terms, do not use the package.

某个 PowerShell 脚本将下载并安装 Azure IoT Edge 安全守护程序。A PowerShell script downloads and installs the Azure IoT Edge security daemon. 然后,安全守护程序将启动两个运行时模块中的第一个,即 IoT Edge 代理,以便能够远程部署其他模块。The security daemon then starts the first of two runtime modules, the IoT Edge agent, which enables remote deployments of other modules.

提示

对于 IoT Core 设备,我们建议使用 RemotePowerShell 会话运行安装命令。For IoT Core devices, we recommend running the installation commands using a RemotePowerShell session. 有关详细信息,请参阅将 PowerShell 用于 Windows IoTFor more information, see Using PowerShell for Windows IoT.

首次在设备上安装 IoT Edge 运行时时,需要使用 IoT 中心内的标识预配该设备。When you install the IoT Edge runtime for the first time on a device, you need to provision the device with an identity from an IoT hub. 可以使用 IoT 中心提供的设备连接字符串手动预配单个 IoT Edge 设备。A single IoT Edge device can be provisioned manually using a device connection string provided by IoT Hub. 或者,可以使用设备预配服务 (DPS) 自动预配设备,需要设置多个设备时,这种做法非常有用。Or, you can use the Device Provisioning Service (DPS) to automatically provision devices, which is helpful when you have many devices to set up. 根据预配选项,选择合适的安装脚本。Depending on your provisioning choice, choose the appropriate installation script.

以下部分介绍新设备上 IoT Edge 安装脚本的常见用例和参数。The following sections describe the common use cases and parameters for the IoT Edge installation script on a new device.

选项 1:安装和手动预配Option 1: Install and manually provision

在这第一个选项中,提供 IoT 中心生成的、用于预配设备的设备连接字符串In this first option, you provide a device connection string generated by IoT Hub to provision the device.

此示例演示使用 Windows 容器进行的手动安装:This example demonstrates a manual installation with Windows containers:

  1. 注册新的 IoT Edge 设备并检索设备连接字符串(如果尚未这样做)。If you haven't already, register a new IoT Edge device and retrieve the device connection string. 复制连接字符串,以便稍后在本部分中使用。Copy the connection string to use later in this section. 可以使用以下工具完成此步骤:You can complete this step using the following tools:

  2. 以管理员身份运行 PowerShell。Run PowerShell as an administrator.

    备注

    使用 PowerShell 的 AMD64 会话安装 IoT Edge,不要使用 PowerShell (x86)。Use an AMD64 session of PowerShell to install IoT Edge, not PowerShell (x86). 如果不确定您使用的是什么会话类型,请运行以下命令:If you're not sure which session type you're using, run the following command:

    (Get-Process -Id $PID).StartInfo.EnvironmentVariables["PROCESSOR_ARCHITECTURE"]
    
  3. Deploy-IoTEdge 命令检查 Windows 计算机是否使用了支持的版本,启用容器功能,然后下载 moby 运行时和 IoT Edge 运行时。The Deploy-IoTEdge command checks that your Windows machine is on a supported version, turns on the containers feature, and then downloads the moby runtime and the IoT Edge runtime. 该命令默认使用 Windows 容器。The command defaults to using Windows containers.

    . {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `
    Deploy-IoTEdge
    
  4. 此时,IoT Core 设备可能会自动重启。At this point, IoT Core devices may restart automatically. 其他 Windows 10 或 Windows Server 设备可能会提示你重启。Other Windows 10 or Windows Server devices may prompt you to restart. 如果是这样,请立即重启设备。If so, restart your device now. 设备准备就绪后,再次以管理员身份运行 PowerShell。Once your device is ready, run PowerShell as an administrator again.

  5. Initialize-IoTEdge 命令在计算机上配置 IoT Edge 运行时。The Initialize-IoTEdge command configures the IoT Edge runtime on your machine. 该命令默认为使用 Windows 容器手动预配。The command defaults to manual provisioning with Windows containers.

    . {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `
    Initialize-IoTEdge
    
  6. 出现提示时,请提供在步骤 1 中检索到的设备连接字符串。When prompted, provide the device connection string that you retrieved in step 1. 该设备连接字符串会将物理设备与 IoT 中心内的设备 ID 相关联。The device connection string associates the physical device with a device ID in IoT Hub.

    该设备连接字符串采用以下格式(不包括引号):HostName={IoT hub name}.azure-devices.cn;DeviceId={device name};SharedAccessKey={key}The device connection string takes the following format, and should not include quotation marks: HostName={IoT hub name}.azure-devices.cn;DeviceId={device name};SharedAccessKey={key}

  7. 使用验证安装是否成功中的步骤检查设备上的 IoT Edge 状态。Use the steps in Verify successful installation to check the status of IoT Edge on your device.

手动安装和预配设备时,可以使用附加的参数来修改安装,包括:When you install and provision a device manually, you can use additional parameters to modify the installation including:

  • 定向流量,使其通过代理服务器Direct traffic to go through a proxy server
  • 将安装程序指向某个脱机目录Point the installer to an offline directory
  • 声明特定的代理容器映像,并提供凭据(如果该映像位于专用注册表中)Declare a specific agent container image, and provide credentials if it's in a private registry

有关这些安装选项的详细信息,请直接跳到所有安装参数For more information about these installation options, skip ahead to learn about all installation parameters.

选项 2:安装和自动预配Option 2: Install and automatically provision

在这第二个选项中,使用 IoT 中心设备预配服务来预配设备。In this second option, you provision the device using the IoT Hub Device Provisioning Service. 提供设备预配服务实例的范围 ID 以及特定于首选证明机制的任何其他信息:Provide the Scope ID from a Device Provisioning Service instance along with any other information specific to your preferred attestation mechanism:

自动安装和预配设备时,可以使用附加的参数来修改安装,包括:When you install and provision a device automatically, you can use additional parameters to modify the installation including:

  • 定向流量,使其通过代理服务器Direct traffic to go through a proxy server
  • 将安装程序指向某个脱机目录Point the installer to an offline directory
  • 声明特定的代理容器映像,并提供凭据(如果该映像位于专用注册表中)Declare a specific agent container image, and provide credentials if it's in a private registry

有关这些安装选项的详细信息,请继续阅读本文,或转到所有安装参数For more information about these installation options, continue reading this article or skip to learn about All installation parameters.

脱机或特定版本安装Offline or specific version installation

在安装过程中,会下载三个文件:During installation three files are downloaded:

  • 一个 PowerShell 脚本,其中包含安装说明A PowerShell script, which contains the installation instructions
  • Microsoft Azure IoT Edge cab,其中包含 IoT Edge 安全守护程序 (iotedged)、Moby 容器引擎和 Moby CLIMicrosoft Azure IoT Edge cab, which contains the IoT Edge security daemon (iotedged), Moby container engine, and Moby CLI
  • Visual C++ Redistributable Package(VC 运行时)安装程序Visual C++ redistributable package (VC runtime) installer

如果在安装过程中设备会脱机,或者要安装 IoT Edge 的特定版本,则可提前将这些文件下载到设备。If your device will be offline during installation, or if you want to install a specific version of IoT Edge, you can download these files ahead of time to the device. 当安装时,请将安装脚本指向包含已下载文件的目录。When it's time to install, point the installation script at the directory that contains the downloaded files. 安装程序首先会检查该目录,然后仅下载未找到的组件。The installer checks that directory first, and then only downloads components that aren't found. 如果所有文件都可脱机使用,则无需连接到 Internet 连接即可安装。If all the files are available offline, you can install with no internet connection.

还可使用脱机安装路径参数来更新 IoT Edge。You can also use the offline installation path parameter to update IoT Edge. 有关详细信息,请参阅更新 IoT Edge 安全守护程序和运行时For more information, see Update the IoT Edge security daemon and runtime.

  1. 有关最新的 IoT Edge 安装文件以及旧版本,请参阅 Azure IoT Edge 版本For the latest IoT Edge installation files along with previous versions, see Azure IoT Edge releases.

  2. 找到要安装的版本,然后从发行说明的“资产”部分将以下文件下载到 IoT 设备上:Find the version that you want to install, and download the following files from the Assets section of the release notes onto your IoT device:

    • IoTEdgeSecurityDaemon.ps1IoTEdgeSecurityDaemon.ps1
    • 1.0.9 或更高版本中的 Microsoft-Azure-IoTEdge-amd64.cab,或者 1.0.8 或更低版本中的 Microsoft-Azure-IoTEdge.cab。Microsoft-Azure-IoTEdge-amd64.cab from releases 1.0.9 or newer, or Microsoft-Azure-IoTEdge.cab from releases 1.0.8 and older.

    从 1.0.9 开始,也可以使用 Microsoft-Azure-IotEdge-arm32.cab(仅用于测试目的)。Microsoft-Azure-IotEdge-arm32.cab is also available beginning in 1.0.9 for testing purposes only. Windows ARM32 设备目前不支持 IoT Edge。IoT Edge is not currently supported on Windows ARM32 devices.

    请务必使用与所用 .cab 文件版本相同的 PowerShell 脚本,因为功能会进行更改以支持每个版本中的特性。It's important to use the PowerShell script from the same release as the .cab file that you use because the functionality changes to support the features in each release.

  3. 如果下载的 .cab 文件在其上有体系结构后缀,则只需将该文件重命名为“Microsoft-Azure-IoTEdge.cab”即可。If the .cab file you downloaded has an architecture suffix on it, rename the file to just Microsoft-Azure-IoTEdge.cab.

  4. (可选)下载 Visual C++ Redistributable 的安装程序。Optionally, download an installer for Visual C++ redistributable. 例如,PowerShell 脚本使用此版本:vc_redist.x64.exeFor example, the PowerShell script uses this version: vc_redist.x64.exe. 将安装程序保存到 IoT 设备上 IoT Edge 文件所在的文件夹中。Save the installer in the same folder on your IoT device as the IoT Edge files.

  5. 若要使用脱机组件进行安装,请使用点获取 PowerShell 脚本本地副本的来源To install with offline components, dot source the local copy of the PowerShell script. 然后,使用 -OfflineInstallationPath 参数作为 Deploy-IoTEdge 命令的一部分,并提供文件目录的绝对路径。Then, use the -OfflineInstallationPath parameter as part of the Deploy-IoTEdge command and provide the absolute path to the file directory. 例如,For example,

    . <path>\IoTEdgeSecurityDaemon.ps1
    Deploy-IoTEdge -OfflineInstallationPath <path>
    

    部署命令会使用已提供的本地文件目录中的任何组件。The deployment command will use any components found in the local file directory provided. 如果缺少 .cab 文件或 Visual C++ 安装程序,部署命令会尝试下载该文件或安装程序。If either the .cab file or the Visual C++ installer is missing, it will attempt to download them.

  6. 运行 Initialize-IoTEdge 命令,使用 IoT 中心的标识来预配设备。Run the Initialize-IoTEdge command to provision your device with an identity in IoT Hub. 提供设备连接字符串进行手动预配,或选择前面的自动预配部分所述的方法之一。Either provide a device connection string for manual provisioning, or choose one of the methods described in the previous automatically provision section.

    如果设备在运行 Deploy-IoTEdge 后重启,请在运行 Initialize-IoTEdge 之前再次使用点来获取 PowerShell 脚本的来源。If your device restarted after running Deploy-IoTEdge, dot source the PowerShell script again before running Initialize-IoTEdge.

有关脱机安装选项的详细信息,请直接跳到所有安装参数For more information about the offline installation option, skip ahead to learn about all installation parameters.

验证是否成功安装Verify successful installation

检查 IoT Edge 服务的状态。Check the status of the IoT Edge service. 该服务应列为“正在运行”。It should be listed as running.

Get-Service iotedge

检查过去 5 分钟的服务日志。Examine service logs from the last 5 minutes. 如果刚刚完成了 IoT Edge 运行时的安装,可能会看到运行 Deploy-IoTEdge 之后、运行 Initialize-IoTEdge 之前发生的错误列表。If you just finished installing the IoT Edge runtime, you may see a list of errors from the time between running Deploy-IoTEdge and Initialize-IoTEdge. 这些错误在预料之中,因为该服务在经过配置之前会尝试启动。These errors are expected, as the service is trying to start before being configured.

. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; Get-IoTEdgeLog

运行故障排除工具,检查最常见的配置和网络错误。Run the troubleshooting tool to check for the most common configuration and networking errors.

iotedge check

在将第一个模块部署到设备上的 IoT Edge 之前, $edgeHub 系统模块不会部署到设备。Until you deploy your first module to IoT Edge on your device, the $edgeHub system module will not be deployed to the device. 因此,自动检查会返回一个针对 Edge Hub can bind to ports on host 连接性检查的错误。As a result, the automated check will return an error for the Edge Hub can bind to ports on host connectivity check. 此错误可以忽略,除非它是在将模块部署到设备后发生的。This error can be ignored unless it occurs after deploying a module to the device.

最后,列出正在运行的模块:Finally, list running modules:

iotedge list

完成新的安装后,应会看到唯一运行的模块是 edgeAgentAfter a new installation, the only module you should see running is edgeAgent. 首次部署 IoT Edge 模块后,其他系统模块 edgeHub 也会在设备上启动。After you deploy IoT Edge modules for the first time, the other system module, edgeHub, will start on the device too.

管理模块容器Manage module containers

IoT Edge 服务要求在设备上运行容器引擎。The IoT Edge service requires a container engine running on your device. 将模块部署到设备时,IoT Edge 运行时将使用容器引擎从云中的注册表提取容器映像。When you deploy a module to a device, the IoT Edge runtime uses the container engine to pull the container image from a registry in the cloud. IoT Edge 服务允许与模块交互和检索日志,但有时,你可能想要使用容器引擎来与容器本身交互。The IoT Edge service enables you to interact with your modules and retrieve logs, but sometimes you may want to use the container engine to interact with the container itself.

有关模块概念的详细信息,请参阅了解 Azure IoT Edge 模块For more information about module concepts, see Understand Azure IoT Edge modules.

如果在 Windows IoT Edge 设备上运行 Windows 容器,则 IoT Edge 安装中已包含 Moby 容器引擎。If you're running Windows containers on your Windows IoT Edge device, then the IoT Edge installation included the Moby container engine. Moby 引擎所基于的标准与 Docker 相同,可在 Docker Desktop 所在的同一台计算机上同时运行。The Moby engine was based on the same standards as Docker, and was designed to run in parallel on the same machine as Docker Desktop. 因此,若要以 Moby 引擎管理的容器为目标,则必须专门将该引擎指定为目标,而不要以 Docker 为目标。For that reason, if you want to target containers managed by the Moby engine, you have to specifically target that engine instead of Docker.

例如,若要列出所有 Docker 映像,可使用以下命令:For example, to list all Docker images, use the following command:

docker images

若要列出所有 Moby 映像,可以使用指向 Moby 引擎的指针修改上述命令:To list all Moby images, modify the same command with a pointer to the Moby engine:

docker -H npipe:////./pipe/iotedge_moby_engine images

引擎 URI 将在安装脚本的输出中列出,也可以在 config.yaml 文件的容器运行时设置节中找到它。The engine URI is listed in the output of the installation script, or you can find it in the container runtime settings section for the config.yaml file.

config.yaml 中的 moby_runtime uri

若要详细了解可以使用哪些命令来与设备上运行的容器和映像交互,请参阅 Docker 命令行接口For more information about commands you can use to interact with containers and images running on your device, see Docker command-line interfaces.

卸载 IoT EdgeUninstall IoT Edge

若要从 Windows 设备中删除 IoT Edge 安装,请在 PowerShell 管理窗口中使用以下命令。If you want to remove the IoT Edge installation from your Windows device, use the following command from an administrative PowerShell window. 此命令会删除 IoT Edge 运行时,以及现有的配置和 Moby 引擎数据。This command removes the IoT Edge runtime, along with your existing configuration and the Moby engine data.

. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Uninstall-IoTEdge

Uninstall-IoTEdge 命令在 Windows IoT Core 中无法运行。The Uninstall-IoTEdge command does not work on Windows IoT Core. 若要从 Windows IoT Core 设备中删除 IoT Edge,需要重新部署 Windows IoT Core 映像。To remove IoT Edge from Windows IoT Core devices, you need to redeploy your Windows IoT Core image.

有关卸载选项的详细信息,请使用命令 Get-Help Uninstall-IoTEdge -fullFor more information about uninstallation options, use the command Get-Help Uninstall-IoTEdge -full.

验证安装脚本Verify installation script

本文中提供的安装命令使用 Invoke-WebRequest cmdlet 从 aka.ms/iotedge-win 请求安装脚本。The installation commands provided in this article use the Invoke-WebRequest cmdlet to request the installation script from aka.ms/iotedge-win. 此链接指向最新 IoT Edge 版本中的 IoTEdgeSecurityDaemon.ps1 脚本。This link points to theIoTEdgeSecurityDaemon.ps1 script from the most recent IoT Edge release. 还可以下载此脚本或某个特定发行版中的脚本版本,以便在 IoT Edge 设备上运行安装命令。You can also download this script, or a version of the script from a specific release, to run the installation commands on your IoT Edge device.

提供的脚本已签名以提高安全性。The provided script is signed to increase security. 若要验证签名,可以将脚本下载到设备,然后运行以下 PowerShell 命令:You can verify the signature by downloading the script to your device then running the following PowerShell command:

Get-AuthenticodeSignature "C:\<path>\IotEdgeSecurityDaemon.ps1"

如果签名获得验证,则输出状态为“有效”。The output status is Valid if the signature is verified.

所有安装参数All installation parameters

前面几个部分介绍了常见安装方案,并举例说明了如何使用参数来修改安装脚本。The previous sections introduced common installation scenarios with examples of how to use parameters to modify the installation script. 本部分提供用于安装、更新或卸载 IoT Edge 的通用参数的参考表格。This section provides reference tables of the common parameters used to install, update, or uninstall IoT Edge.

Deploy-IoTEdgeDeploy-IoTEdge

Deploy-IoTEdge 命令下载并部署 IoT Edge 安全守护程序及其依赖项。The Deploy-IoTEdge command downloads and deploys the IoT Edge Security Daemon and its dependencies. 该部署命令接受这些通用参数,此外还接受其他一些参数。The deployment command accepts these common parameters, among others. 有关完整列表,请使用命令 Get-Help Deploy-IoTEdge -fullFor the full list, use the command Get-Help Deploy-IoTEdge -full.

参数Parameter 接受的值Accepted values 注释Comments
ContainerOsContainerOs WindowsLinuxWindows or Linux 如果未指定容器操作系统,则 Windows 是默认值。If no container operating system is specified, Windows is the default value.

对于 Windows 容器,IoT Edge 使用安装中包含的 moby 容器引擎。For Windows containers, IoT Edge uses the moby container engine included in the installation. 对于 Linux 容器,需要在开始安装之前安装容器引擎。For Linux containers, you need to install a container engine before starting the installation.
ProxyProxy 代理 URLProxy URL 如果设备需要通过代理服务器来连接 Internet,请包含此参数。Include this parameter if your device needs to go through a proxy server to reach the internet. 有关详细信息,请参阅将 IoT Edge 设备配置为通过代理服务器进行通信For more information, see Configure an IoT Edge device to communicate through a proxy server.
OfflineInstallationPathOfflineInstallationPath 目录路径Directory path 如果包含此参数,则安装程序将在列出的目录中检查安装时所需的 IoT Edge cab 和 VC 运行时 MSI 文件。If this parameter is included, the installer will check the listed directory for the IoT Edge cab and VC Runtime MSI files required for installation. 系统会下载该目录中不存在的任何文件。Any files not found in the directory are downloaded. 如果这两个文件在该目录中存在,则无需建立 Internet 连接即可安装 IoT Edge。If both files are in the directory, you can install IoT Edge without an internet connection. 还可以通过此参数来使用特定的版本。You can also use this parameter to use a specific version.
InvokeWebRequestParametersInvokeWebRequestParameters 参数和值的哈希表Hashtable of parameters and values 在安装期间,会发出多个 Web 请求。During installation, several web requests are made. 请使用此字段来设置这些 Web 请求的参数。Use this field to set parameters for those web requests. 此参数可用于配置代理服务器的凭据。This parameter is useful to configure credentials for proxy servers. 有关详细信息,请参阅将 IoT Edge 设备配置为通过代理服务器进行通信For more information, see Configure an IoT Edge device to communicate through a proxy server.
RestartIfNeededRestartIfNeeded none 此标志可让部署脚本在无提示的情况下根据需要重启计算机。This flag allows the deployment script to restart the machine without prompting, if necessary.

Initialize-IoTEdgeInitialize-IoTEdge

Initialize-IoTEdge 命令使用设备连接字符串和操作详细信息配置 IoT Edge。The Initialize-IoTEdge command configures IoT Edge with your device connection string and operational details. 然后,此命令生成的许多信息将存储在 iotedge\config.yaml 文件中。Much of the information generated by this command is then stored in the iotedge\config.yaml file. 该初始化命令接受这些通用参数,此外还接受其他一些参数。The initialization command accepts these common parameters, among others. 有关完整列表,请使用命令 Get-Help Initialize-IoTEdge -fullFor the full list, use the command Get-Help Initialize-IoTEdge -full.

参数Parameter 接受的值Accepted values 注释Comments
手动Manual None 开关参数Switch parameter. 如果未指定预配类型,则 manual 是默认值。If no provisioning type is specified, manual is the default value.

声明你要提供设备连接字符串来手动预配设备Declares that you will provide a device connection string to provision the device manually
DpsDps None 开关参数Switch parameter. 如果未指定预配类型,则 manual 是默认值。If no provisioning type is specified, manual is the default value.

声明你要提供设备预配服务 (DPS) 范围 ID 和设备的注册 ID,以通过 DPS 进行预配。Declares that you will provide a Device Provisioning Service (DPS) scope ID and your device's Registration ID to provision through DPS.
DeviceConnectionStringDeviceConnectionString 已在 IoT 中心注册的 IoT Edge 设备中的连接字符串,括在单引号中A connection string from an IoT Edge device registered in an IoT Hub, in single quotes 进行手动预配所需。Required for manual provisioning. 如果未在脚本参数中提供连接字符串,系统会提示你提供一个。If you don't provide a connection string in the script parameters, you will be prompted for one.
ScopeIdScopeId 与 IoT 中心关联的设备预配服务实例中的范围 ID。A scope ID from an instance of Device Provisioning Service associated with your IoT Hub. 进行 DPS 预配所需。Required for DPS provisioning. 如果未在脚本参数中提供范围 ID,系统会提示你提供一个。If you don't provide a scope ID in the script parameters, you will be prompted for one.
RegistrationIdRegistrationId 设备生成的注册 IDA registration ID generated by your device 如果使用 TPM 或对称密钥证明,则为 DPS 预配所需。Required for DPS provisioning if using TPM or symmetric key attestation. 如果使用 X.509 证书证明,则为可选。Optional if using X.509 certificate attestation.
X509IdentityCertificateX509IdentityCertificate 设备上的 X.509 设备标识证书的 URI 路径。The URI path to the X.509 device identity certificate on the device. 如果使用 X.509 证书证明,则为 DPS 预配所需。Required for DPS provisioning if using X.509 certificate attestation.
X509IdentityPrivateKeyX509IdentityPrivateKey 设备上的 X.509 设备标识证书密钥的 URI 路径。The URI path to the X.509 device identity certificate key on the device. 如果使用 X.509 证书证明,则为 DPS 预配所需。Required for DPS provisioning if using X.509 certificate attestation.
SymmetricKeySymmetricKey 使用 DPS 时用于预配 IoT Edge 设备标识的对称密钥The symmetric key used to provision the IoT Edge device identity when using DPS 如果使用对称密钥证明,则为 DPS 预配所需。Required for DPS provisioning if using symmetric key attestation.
ContainerOsContainerOs WindowsLinuxWindows or Linux 如果未指定容器操作系统,则 Windows 是默认值。If no container operating system is specified, Windows is the default value.

对于 Windows 容器,IoT Edge 使用安装中包含的 moby 容器引擎。For Windows containers, IoT Edge uses the moby container engine included in the installation. 对于 Linux 容器,需要在开始安装之前安装容器引擎。For Linux containers, you need to install a container engine before starting the installation.
InvokeWebRequestParametersInvokeWebRequestParameters 参数和值的哈希表Hashtable of parameters and values 在安装期间,会发出多个 Web 请求。During installation, several web requests are made. 请使用此字段来设置这些 Web 请求的参数。Use this field to set parameters for those web requests. 此参数可用于配置代理服务器的凭据。This parameter is useful to configure credentials for proxy servers. 有关详细信息,请参阅将 IoT Edge 设备配置为通过代理服务器进行通信For more information, see Configure an IoT Edge device to communicate through a proxy server.
AgentImageAgentImage IoT Edge 代理映像 URIIoT Edge agent image URI 默认情况下,新的 IoT Edge 安装使用 IoT Edge 代理映像的最新滚动标记。By default, a new IoT Edge installation uses the latest rolling tag for the IoT Edge agent image. 使用此参数可为映像版本设置特定的标记,或者提供自己的代理映像。Use this parameter to set a specific tag for the image version, or to provide your own agent image. 有关详细信息,请参阅了解 IoT Edge 标记For more information, see Understand IoT Edge tags.
用户名Username 容器注册表用户名Container registry username 仅当针对专用注册表中的容器设置了 -AgentImage 参数时,才使用此参数。Use this parameter only if you set the -AgentImage parameter to a container in a private registry. 提供有权访问注册表的用户名。Provide a username with access to the registry.
密码Password 安全密码字符串Secure password string 仅当针对专用注册表中的容器设置了 -AgentImage 参数时,才使用此参数。Use this parameter only if you set the -AgentImage parameter to a container in a private registry. 提供用于访问注册表的密码。Provide the password to access the registry.

Update-IoTEdgeUpdate-IoTEdge

参数Parameter 接受的值Accepted values 注释Comments
ContainerOsContainerOs WindowsLinuxWindows or Linux 如果未指定容器 OS,则 Windows 是默认值。If no container OS is specified, Windows is the default value. 对于 Windows 容器,安装中会包含一个容器引擎。For Windows containers, a container engine will be included in the installation. 对于 Linux 容器,需要在开始安装之前安装容器引擎。For Linux containers, you need to install a container engine before starting the installation.
ProxyProxy 代理 URLProxy URL 如果设备需要通过代理服务器来连接 Internet,请包含此参数。Include this parameter if your device needs to go through a proxy server to reach the internet. 有关详细信息,请参阅将 IoT Edge 设备配置为通过代理服务器进行通信For more information, see Configure an IoT Edge device to communicate through a proxy server.
InvokeWebRequestParametersInvokeWebRequestParameters 参数和值的哈希表Hashtable of parameters and values 在安装期间,会发出多个 Web 请求。During installation, several web requests are made. 请使用此字段来设置这些 Web 请求的参数。Use this field to set parameters for those web requests. 此参数可用于配置代理服务器的凭据。This parameter is useful to configure credentials for proxy servers. 有关详细信息,请参阅将 IoT Edge 设备配置为通过代理服务器进行通信For more information, see Configure an IoT Edge device to communicate through a proxy server.
OfflineInstallationPathOfflineInstallationPath 目录路径Directory path 如果包含此参数,则安装程序将在列出的目录中检查安装时所需的 IoT Edge cab 和 VC 运行时 MSI 文件。If this parameter is included, the installer will check the listed directory for the IoT Edge cab and VC Runtime MSI files required for installation. 系统会下载该目录中不存在的任何文件。Any files not found in the directory are downloaded. 如果这两个文件在该目录中存在,则无需建立 Internet 连接即可安装 IoT Edge。If both files are in the directory, you can install IoT Edge without an internet connection. 还可以通过此参数来使用特定的版本。You can also use this parameter to use a specific version.
RestartIfNeededRestartIfNeeded none 此标志可让部署脚本在无提示的情况下根据需要重启计算机。This flag allows the deployment script to restart the machine without prompting, if necessary.

Uninstall-IoTEdgeUninstall-IoTEdge

参数Parameter 接受的值Accepted values 注释Comments
ForceForce none 在上次尝试卸载失败时,此标志会强制卸载。This flag forces the uninstallation in case the previous attempt to uninstall was unsuccessful.
RestartIfNeededRestartIfNeeded none 此标志可让卸载脚本在无提示的情况下根据需要重启计算机。This flag allows the uninstall script to restart the machine without prompting, if necessary.

后续步骤Next steps

预配了安装运行时的 IoT Edge 设备后,现在可以部署 IoT Edge 模块Now that you have an IoT Edge device provisioned with the runtime installed, you can deploy IoT Edge modules.

如果无法正常安装 IoT Edge,请查看故障排除页。If you are having problems installing IoT Edge properly, check out the troubleshooting page.

若要将现有安装更新到最新版本的 IoT Edge,请参阅更新 IoT Edge 安全守护程序和运行时To update an existing installation to the newest version of IoT Edge, see Update the IoT Edge security daemon and runtime.