通过 Azure 门户部署 Azure IoT Edge 模块Deploy Azure IoT Edge modules from the Azure portal

使用业务逻辑创建 IoT Edge 模块后,需要将其部署到设备后才能在边缘操作。Once you create IoT Edge modules with your business logic, you want to deploy them to your devices to operate at the edge. 如果多个模块共同协作来收集和处理数据,可同时部署它们并声明用于连接它们的路由规则。If you have multiple modules that work together to collect and process data, you can deploy them all at once and declare the routing rules that connect them.

本文介绍了 Azure 门户如何引导创建部署清单并将部署推送给 IoT Edge 设备。This article shows how the Azure portal guides you through creating a deployment manifest and pushing the deployment to an IoT Edge device. 有关基于多个设备的共享标签创建针对这些设备的部署的信息,请参阅大规模地部署和监视 IoT Edge 模块For information about creating a deployment that targets multiple devices based on their shared tags, see Deploy and monitor IoT Edge modules at scale.


配置部署清单Configure a deployment manifest

部署清单是一个 JSON 文档,其中描述了要部署的模块、数据在模块间的流动方式以及模块孪生的所需属性。A deployment manifest is a JSON document that describes which modules to deploy, how data flows between the modules, and desired properties of the module twins. 若要详细了解部署清单的工作原理及创建方式,请参阅了解如何使用、配置和重用 IoT Edge 模块For more information about how deployment manifests work and how to create them, see Understand how IoT Edge modules can be used, configured, and reused.

Azure 门户提供部署清单的创建向导,无需你手动构建 JSON 文档。The Azure portal has a wizard that walks you through creating the deployment manifest, instead of building the JSON document manually. 它分为三步:添加模块、指定路由和评审部署 。It has three steps: Add modules, Specify routes, and Review deployment.

选择设备并添加模块Select device and add modules

  1. 登录 Azure 门户,导航到 IoT 中心。Sign in to the Azure portal and navigate to your IoT hub.

  2. 在左窗格的菜单中,选择“IoT Edge”。On the left pane, select IoT Edge from the menu.

  3. 在设备列表中单击目标设备的 ID。Click on the ID of the target device from the list of devices.

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

  5. 在此页的“容器注册表设置”部分,提供用于访问包含模块映像的任何专用容器注册表的凭据。In the Container Registry Settings section of the page, provide the credentials to access any private container registries that contain your module images.

  6. 在此页的“IoT Edge 模块”部分,选择“添加” 。In the IoT Edge Modules section of the page, select Add.

  7. 从下拉菜单中查看模块类型:Look at the types of modules from the drop-down menu:

    • IoT Edge 模块 - 提供模块名称和容器映像 URI。IoT Edge Module - You provide the module name and container image URI. 例如,示例 SimulatedTemperatureSensor 模块的映像 URI 为 mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0For example, the image URI for the sample SimulatedTemperatureSensor module is mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0. 如果模块映像存储在专用容器注册表中,则在此页面上添加凭据来访问该映像。If the module image is stored in a private container registry, add the credentials on this page to access the image.
    • 市场模块 - Azure 市场中托管的模块。Marketplace Module - Modules hosted in the Azure Marketplace. 某些市场模块需要其他配置,因此请查看 Azure 市场 IoT Edge 模块列表中的模块详细信息。Some marketplace modules require additional configuration, so review the module details in the Azure Marketplace IoT Edge Modules list.
    • Azure 流分析模块 - 通过 Azure 流分析工作负载生成的模块。Azure Stream Analytics Module - Modules generated from an Azure Stream Analytics workload.
  8. 添加模块后,从列表中选择模块名称以打开模块设置。After adding a module, select the module name from the list to open the module settings. 必要时请填写可选字段。Fill out the optional fields if necessary. 要详细了解容器创建选项、重启策略和所需状态,请参阅 EdgeAgent 必需属性For more information about container create options, restart policy, and desired status see EdgeAgent desired properties. 要详细了解模块孪生,请参阅定义或更新所需属性For more information about the module twin see Define or update desired properties.

  9. 如果需要,请重复步骤 5 到 8,向部署中添加其他模块。If needed, repeat steps 5 through 8 to add additional modules to your deployment.

  10. 在完成时选择“下一步:路由”继续转到路由部分。Select Next: Routes to continue to the routes section.

指定路由Specify routes

在“路由”选项卡中,定义消息在模块和 IoT 中心之间传递的方式。On the Routes tab, you define how messages are passed between modules and the IoT Hub. 使用名称/值对构造消息。Messages are constructed using name/value pairs. 默认情况下,系统将路由命名为“route”并定义为“FROM /messages/* INTO $upstream”,这意味着任何模块输出的任何消息都将发送到 IoT 中心。By default a route is called route and defined as FROM /messages/* INTO $upstream, which means that any messages output by any modules are sent to your IoT hub.

在路由中添加或更新声明路由中的信息,然后选择“下一步:查看 + 创建”以继续执行向导的下一步。Add or update the routes with information from Declare routes, then select Next: Review + create to continue to the next step of the wizard.

评审部署Review deployment

评审部分介绍了根据上述两部分中的选择所创建的 JSON 部署清单。The review section shows you the JSON deployment manifest that was created based on your selections in the previous two sections. 请注意,$edgeAgent 和 $edgeHub 模块已声明但却未添加 。Note that there are two modules declared that you didn't add: $edgeAgent and $edgeHub. 这两个模块构成 IoT Edge 运行时,且是每个部署中所需的默认设置。These two modules make up the IoT Edge runtime and are required defaults in every deployment.

查看部署信息,然后选择“创建”。Review your deployment information, then select Create.

查看设备上的模块View modules on your device

将模块部署到设备之后,即可在 IoT 中心的设备详细信息页中查看所有模块。Once you've deployed modules to your device, you can view all of them in the device details page of your IoT Hub. 此页面显示每个已部署模块的名称,以及部署状态和退出代码等有用信息。This page displays the name of each deployed module, as well as useful information like the deployment status and exit code.

从 Azure 市场部署模块Deploy modules from Azure Marketplace

Azure 市场是一个在线应用程序和服务市场,可在其中浏览各种企业级应用程序和解决方案,这些应用程序和解决方案进行了认证和优化以在 Azure 上运行,包括 IoT Edge 模块Azure Marketplace is an online applications and services marketplace where you can browse through a wide range of enterprise applications and solutions that are certified and optimized to run on Azure, including IoT Edge modules.

可以从 Azure 市场和 IoT 中心部署 IoT Edge 模块。You can deploy an IoT Edge module from the Azure Marketplace and from your IoT Hub.

从 Azure 市场部署Deploy from Azure Marketplace

详细考察市场中的 IoT Edge 模块,找到所需的模块后,可以通过选择“创建”或“立即获取”来部署它 。Peruse the IoT Edge modules in the marketplace and when you find the one you want you can deploy it by selecting Create or Get it now. 继续执行部署向导步骤,这些步骤可能会因所选的 IoT Edge 模块而异:Proceed with the deployment wizard steps which may vary depending on the IoT Edge module you selected:

  1. 通过选择“继续”,承认提供商的使用条款和隐私政策。Acknowledge the provider's terms of use and privacy policy by selecting Continue. 你可能首先需要提供联系信息。You may first have to provide contact information.
  2. 选择你的订阅和要将目标设备附加到的 IoT 中心。Choose your subscription and the IoT Hub to which the target device is attached.
  3. 选择“部署到设备”。Choose Deploy to a device.
  4. 输入设备的名称,或选择“查找设备”以浏览注册到中心的设备。Enter the name of the device or select Find Device to browse among the devices registered with the hub.
  5. 选择“创建”以继续配置部署清单的标准过程,包括根据需要添加其他模块。Select Create to continue the standard process of configuring a deployment manifest, including adding other modules if desired. 新模块的详细信息(例如映像 URI、创建选项以及所需的属性)已预定义,但可以更改。Details for the new module such as image URI, create options, and desired properties are predefined but can be changed.

验证该模块是否已部署在 Azure 门户的 IoT 中心。Verify that the module is deployed in your IoT Hub in the Azure portal. 选择设备,选择”设置模块“,该模块应列在“IoT Edge 模块”部分中 。Select your device, select Set Modules and the module should be listed in the IoT Edge Modules section.

从 Azure IoT 中心部署Deploy from Azure IoT Hub

可以将 Azure 市场中的模块快速部署到 Azure 门户的 IoT 中心的设备上。You can quickly deploy a module from the Azure Marketplace onto your device in your IoT Hub in the Azure portal.

  1. 在 Azure 门户中,导航到 IoT 中心。In the Azure portal, navigate to your IoT Hub.
  2. 在左窗格的“自动设备管理”下,选择“IoT Edge” 。On the left pane, under Automatic Device Management, select IoT Edge.
  3. 选择要接收部署的 IoT Edge 设备。Select the IoT Edge device that is to receive the deployment.
  4. 在上方栏中,选择“设置模块”。On the upper bar, select Set Modules.
  5. 在“IoT Edge 模块”部分中,单击“添加”,然后从下拉菜单中选择“市场模块”。In the IoT Edge Modules section, click Add, and select Marketplace Module from the drop-down menu.

在 IoT 中心添加模块

从“IoT Edge 模块市场”页面选择一个模块。Choose a module from the IoT Edge Module Marketplace page. 系统会自动为你的订阅、资源组和设备配置所选的模块。The module you select is automatically configured for your subscription, resource group, and device. 然后,所选模块将显示在 IoT Edge 模块列表中。It then appears in your list of IoT Edge modules. 某些模块可能需要其他配置。Some modules may require additional configuration.


Azure IoT 中心提供的有关 IoT Edge 模块的信息是有限的。The information about IoT Edge modules from the Azure IoT Hub is limited. 你可以先在 Azure 市场中了解有关 IoT Edge 模块的详细信息。You can first learn more about the IoT Edge modules in the Azure Marketplace.

在完成时选择“下一步:路由”,并按本文前面的指定路由查看部署所述继续进行部署。Select Next: Routes and continue with deployment as described by Specify routes and Review Deployment earlier in this article.

后续步骤Next steps

了解如何大规模地部署和监视 IoT Edge 模块Learn how to Deploy and monitor IoT Edge modules at scale