使用 Azure 门户设置 IoT 中心设备预配服务Set up the IoT Hub Device Provisioning Service with the Azure portal

以下步骤演示了如何在门户中设置用于预配设备的 Azure 云资源。These steps show how to set up the Azure cloud resources in the portal for provisioning your devices. 本文包括用于以下操作的步骤:创建 IoT 中心、创建新的 IoT 中心设备预配服务,以及将两个服务链接到一起。This article includes steps for: creating your IoT hub, creating a new IoT Hub Device Provisioning Service, and linking the two services together.

如果没有 Azure 订阅,可以在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

创建 IoT 中心Create an IoT hub

此部分介绍如何使用 Azure 门户创建 IoT 中心。This section describes how to create an IoT hub using the Azure portal.

  1. 登录到 Azure 门户Log in to the Azure portal.

  2. 选择“+创建资源”,然后搜索市场,寻找 IoT 中心Choose +Create a resource, then Search the Marketplace for the IoT Hub.

  3. 选择“IoT 中心”,然后单击“创建”按钮 。Select IoT Hub and click the Create button. 随即显示 IoT 中心创建过程的第一个屏幕。You see the first screen for creating an IoT hub.

    在 Azure 门户中创建中心

    填充字段。Fill in the fields.

    订阅:请选择要用于 IoT 中心的订阅。Subscription: Select the subscription to use for your IoT hub.

    资源组:可创建新的资源组或使用现有资源组。Resource Group: You can create a new resource group or use an existing one. 若要新建一个,请单击“新建” ,并填写要使用的名称。To create a new one, click Create new and fill in the name you want to use. 若要使用现有资源组,请单击“使用现有资源组” 并从下拉列表中选择该组。To use an existing resource group, click Use existing and select the resource group from the dropdown list. 有关详细信息,请参阅管理 Azure 资源管理器资源组For more information, see Manage Azure Resource Manager resource groups.

    区域:这是要在其中设置中心的区域。Region: This is the region in which you want your hub to be located. 从下拉列表中选择最靠近自己的位置。Select the location closest to you from the dropdown list.

    IoT 中心名称:输入 IoT 中心的名称。IoT Hub Name: Put in the name for your IoT Hub. 此名称必须全局唯一。This name must be globally unique. 如果输入的名称可用,会显示一个绿色复选标记。If the name you enter is available, a green check mark appears.

    Important

    IoT 中心将公开为 DNS 终结点,因此,命名时请务必避免包含任何敏感信息。The IoT hub will be publicly discoverable as a DNS endpoint, so make sure to avoid any sensitive information while naming it.

  4. 单击“下一步: 大小和规模”,以便继续创建 IoT 中心。Click Next: Size and scale to continue creating your IoT hub.

    使用 Azure 门户为新的 IoT 中心设置大小和缩放级别

    在此屏幕上,可以采用默认值,只需在底部单击“查看+创建”即可 。On this screen, you can take the defaults and just click Review + create at the bottom.

    定价和缩放层:可以根据你需要的功能数以及每天通过解决方案发送的消息数从多个层中进行选择。Pricing and scale tier: You can choose from several tiers depending on how many features you want and how many messages you send through your solution per day. 免费层适用于测试和评估。The free tier is intended for testing and evaluation. 它允许 500 台设备连接到 IoT 中心,并且每天最多传输 8,000 条信息。It allows 500 devices to be connected to the IoT hub and up to 8,000 messages per day. 每个 Azure 订阅可以在免费层中创建一个 IoT 中心。Each Azure subscription can create one IoT Hub in the free tier.

    IoT 中心单元:每个单位每日允许的消息数取决于中心的定价层。IoT Hub units: The number of messages allowed per unit per day depends on your hub's pricing tier. 例如,如果希望 IoT 中心支持 700,000 条消息输入,则选择两个 S1 层单位。For example, if you want the IoT hub to support ingress of 700,000 messages, you choose two S1 tier units.

    有关其他层选项的详细信息,请参阅选择合适的 IoT 中心层For details about the other tier options, see Choosing the right IoT Hub tier.

    高级 / 设备到云分区:此属性将设备到云消息与这些消息的同步读取器数目相关联。Advanced / Device-to-cloud partitions: This property relates the device-to-cloud messages to the number of simultaneous readers of the messages. 大多数 IoT 中心只需要 4 个分区。Most IoT hubs only need four partitions.

  5. 单击“查看+创建” 可查看选择。Click Review + create to review your choices. 会显示类似于以下的屏幕。You see something similar to this screen.

    查看用于创建新 IoT 中心的信息

  6. 单击“创建”以创建新的 IoT 中心 。Click Create to create your new IoT hub. 创建中心需要几分钟时间。Creating the hub takes a few minutes.

为 IoT 中心设备预配服务创建新实例Create a new instance for the IoT Hub Device Provisioning Service

  1. 单击 Azure 门户左上角的“创建资源”按钮。Click the Create a resource button found on the upper left-hand corner of the Azure portal.

  2. *在市场中搜索*设备预配服务Search the Marketplace for the Device provisioning service. 选择“IoT 中心设备预配服务”,然后单击“创建”按钮。Select IoT Hub Device Provisioning Service and click the Create button.

  3. 提供新的设备预配服务实例的以下信息,然后单击“创建”。Provide the following information for your new Device Provisioning service instance and click Create.

    • 名称: 为新的设备预配服务实例提供唯一名称。Name: Provide a unique name for your new Device Provisioning service instance. 如果输入的名称可用,会显示一个绿色复选标记。If the name you enter is available, a green check mark appears.

    • 订阅: 选择要用来创建此设备预配服务实例的订阅。Subscription: Choose the subscription that you want to use to create this Device Provisioning service instance.

    • 资源组: 此字段允许你创建新的资源组,或选择现有资源组来包含新实例。Resource group: This field allows you to create a new resource group, or choose an existing one to contain the new instance. 选择包含你之前创建的 IoT 中心的同一资源组,例如 TestResourcesChoose the same resource group that contains the Iot hub you created above, for example, TestResources. 通过将所有相关资源都放在一个组中,可以一起管理它们。By putting all related resources in a group together, you can manage them together. 例如,删除资源组会删除包含在该组中的所有资源。For example, deleting the resource group deletes all resources contained in that group.

    • 位置: 选择离你的设备最近的位置。Location: Select the closest location to your devices.

      在门户边栏选项卡中输入有关设备预配服务实例的基本信息

  4. 单击通知按钮可监视资源实例的创建过程。Click the notification button to monitor the creation of the resource instance. 成功部署服务以后,请单击“固定到仪表板”,然后单击“转到资源”。Once the service is successfully deployed, click Pin to dashboard, and then Go to resource.

    监视部署通知

在本部分中,你将向设备预配服务实例添加配置。In this section, you will add a configuration to the Device Provisioning service instance. 此配置设置将为其预配设备的 IoT 中心。This configuration sets the IoT hub for which devices will be provisioned.

  1. 在 Azure 门户的左侧菜单中单击“所有资源”按钮。Click the All resources button from the left-hand menu of the Azure portal. 选择在上一部分中创建的设备预配服务实例。Select the Device Provisioning service instance that you created in the preceding section.

  2. 在设备预配服务摘要边栏选项卡上,选择“链接的 IoT 中心”。On the Device Provisioning Service summary blade, select Linked IoT hubs. 单击显示在顶部的“+ 添加”按钮。Click the + Add button seen at the top.

  3. 在“添加 IoT 中心的链接”页上,提供以下信息来将新的设备预配服务实例链接到 IoT 中心。On the Add link to IoT hub page, provide the following information to link your new Device Provisioning service instance to an IoT hub. 然后单击“保存”。Then click Save.

    • 订阅: 选择包含要与新的设备预配服务实例进行链接的 IoT 中心的订阅。Subscription: Select the subscription containing the IoT hub that you want to link with your new Device Provisioning service instance.

    • IoT 中心: 选择要与新的设备预配服务实例进行链接的 IoT 中心。Iot hub: Select the IoT hub to link with your new Device Provisioning service instance.

    • 访问策略: 选择“iothubowner”作为用于与 IoT 中心建立链接的凭据。Access Policy: Select iothubowner as the credentials for establishing the link with the IoT hub.

      链接中心名称,以便链接到门户边栏选项卡中的设备预配服务实例

  4. 此时会在“链接的 IoT 中心”边栏选项卡下看到所选中心。Now you should see the selected hub under the Linked IoT hubs blade. 可能需要单击“刷新”才能显示“链接的 IoT 中心”。You might need to click Refresh to show Linked IoT hubs.

清理资源Clean up resources

本教程系列中的其他快速入门教程是在本文的基础上制作的。Other Quickstarts in this collection build upon this Quickstart. 如果打算继续学习后续的快速入门或相关教程,请不要清理在本快速入门中创建的资源。If you plan to continue on to work with subsequent Quickstarts or with the tutorials, do not clean up the resources created in this Quickstart. 如果不打算继续,请在 Azure 门户中执行以下步骤,删除本快速入门创建的所有资源。If you do not plan to continue, use the following steps to delete all resources created by this Quickstart in the Azure portal.

  1. 在 Azure 门户的左侧菜单中单击“所有资源”,然后选择设备预配服务。From the left-hand menu in the Azure portal, click All resources and then select your Device Provisioning service. 在“所有资源”边栏选项卡的顶部单击“删除”。At the top of the All resources blade, click Delete.
  2. 在 Azure 门户的左侧菜单中单击“所有资源”,然后选择 IoT 中心。From the left-hand menu in the Azure portal, click All resources and then select your IoT hub. 在“所有资源”边栏选项卡的顶部单击“删除”。At the top of the All resources blade, click Delete.

后续步骤Next steps

在本快速入门中,你已部署 IoT 中心和设备预配服务实例,并链接了这两个资源。In this Quickstart, you’ve deployed an IoT hub and a Device Provisioning service instance, and linked the two resources. 若要了解如何使用此设置来预配模拟设备,请继续学习本快速入门中关于如何创建模拟设备的内容。To learn how to use this set up to provision a simulated device, continue to the Quickstart for creating simulated device.