一起学Azure Sphere(5)- 将Azure Sphere 预配到Azure China

注意:

本文实际上介绍的是通过DPS 连接多租户IoT Hub的一个案例:

通过Azure Global DPS将设备预配到Azure China IoT Hub- Link Azure IoT Hub on Azure China to Device provisioning Service on Azure Global

 

本节内容介绍如下:如何讲Azure Sphere 预配到中国区的Azure IoT Hub

1. 在Azure global 创建DPS;

2.在Azure China 创建IoT Hub;

3.通过Azure CLI 连接Azure China IoT Hub 到Azure Global DPS;

4. 将Azure Sphere 通过Azure Global DPS注册到Azure China IoT Hub;

 

视频介绍:

 

您可以在B站观看本文视频讲解:https://www.bilibili.com/video/BV1Y7411C7e1/

 

图文介绍:

 

实战步骤:

1. 在Azure global 创建DPS;

2.在Azure China 创建IoT Hub;

3.通过Azure CLI 连接Azure China IoT Hub 到Azure Global DPS;

4. 将Azure Sphere 通过Azure Global DPS注册到Azure China IoT Hub;

 

本文仅对步骤3进行演示,其余内容在其他文章中介绍过了,不再重复。

 

很多场景下,我们需要配置DPS 连接多租户IoT Hub的情况:

比如:

1. 设备制造商提供一个DPS,但是实际的Azure IoT Hub由客户自己提供并保存所有数据;

2. 将某一类带有区域特性的设备注册到指定的Azure IoT Hub,比如将某一款中文语音的扫地机器人注册到中国区Azure IoT Hub, 英文版注册到美国西部Azure 区域;

3. 将特定的产品根据用户所属地注册到特定的Azure 区域,比如本例中的,假设某款应用了Azure Sphere的设备,仅在中国发售,则需要将Azure Sphere注册到Azure 中国。

DPS的多租户配置见官网文档:https://docs.microsoft.com/zh-cn/azure/iot-dps/how-to-provision-multitenant

 

正常的 单租户配置可以通过Azure Portal中的下拉列表选择Azure IoT Hub的方式,见下图:

img-66049336-821d-4ac4-a08d-4e30b7b2c2e8.png

 

多租户场景下,无法在自己的租户下看到别人的IoT Hub,无法在Portal上完成。

此时可以使用Azure CLI,在本例中,我们使用Cloud shll 完成命令:

img-7cf4b8b5-89eb-40f5-9c8e-3ccfb028b3e8.png

执行的命令参见:

az iot dps linked-hub create --connection-string  “目标IoT Hub连接字符串,注意保留双引号”
                             --dps-name
                             --location
                             --resource-group
                             [--allocation-weight]
                             [--apply-allocation-policy {false, true}]
                             [--no-wait]
                             [--subscription]

 

其中必选参数为下:

--connection-string

目标IoT Hub,本例中为Azure 中国的IoT Hub 连接字符串,可在如下位置找到:

img-eb0a6f75-9552-4759-8730-27978a6774c9.png

--dps-name

本例中Global Azure的DPS名称

--location 

IoT Hub的 location,本例中为中国东部2,chinaeast2

--resource-group

DPS的resource group

在页面下方执行:

img-20c9d013-eee1-465d-854e-59d66b762581.png

本例中,执行如下:

az iot dps linked-hub create 
--connection-string "HostName=xxx.azuredevices.cn;SharedAccessKeyName=iothubowner;SharedAccessKey=xxx" --dps-name dps-global-seanyu 
--location chinaeast2 
--resource-group seanyu_azure_sphere_test

执行完成可以在 页面上查看结果:

img-b8bd4ef2-cacf-4f2c-b9d0-a76d2391123e.png

 

 

实际上到此已经结束了。

 

可以通过 文章《使用DPS通过对称密钥进行单个设备注册》进行创建组注册或单个注册并通过模拟设备进行测试,是否能通过Azure Global 的DPS 将设备注册到Azure China中国区IoT Hub。

 

 

 

本系列其他内容:

  1. (视频)一起学Azure Sphere(1)- 什么是 Azure Sphere

  2. (视频)一起学Azure Sphere(2)- 准备 Azure Sphere开发环境并声明设备

  3. (视频)一起学Azure Sphere(3)- 本地开发调试高级程序,上传映像后云端部署到设备

  4. (视频)一起学Azure Sphere(4)- 将Azure Sphere 通过DPS注册到Azure IoT Hub并发送遥测消息

  5. (视频)一起学Azure Sphere(5)- 将Azure Sphere 预配到Azure China IoT Hub

  6. (视频)一起学Azure Sphere(6)- 30分钟内将Azure Sphere 连接到Azure IoT Central并展示基本图表

 


猜你喜欢

转载自blog.51cto.com/10117438/2486630