简体   繁体   English

如何通过REST API或SDK在IoT中心中创建设备

[英]How to create a device in IoT Hub via REST API or SDK

I want to create a device in the IoT Hub when I add a device in my application. 当我在应用程序中添加设备时,我想在IoT中心中创建设备。

I'm looking for REST Endpoints available for performing operation. 我正在寻找可用于执行操作的REST端点。 Or any SDK available to do this. 或任何可用于执行此操作的SDK。

Have a look at the following docs: 看看以下文档:

Service - Create Or Update Device 服务-创建或更新设备

Control access to IoT Hub 控制对IoT中心的访问

example of the creating DeviceX with auto-generated symmetric keys: 使用自动生成的对称密钥创建DeviceX的示例:

PUT https://myIoTHubName.azure-devices.net/devices/DeviceX?api-version=2018-06-30

headers: 标题:

Authorization: sasToken(see the above link)

payload: 有效载荷:

{
  "deviceId": "DeviceX"
}

Here you can find an example of how to using ServiceClient JAVA SDK. 在这里,您可以找到有关如何使用ServiceClient JAVA SDK的示例。 For connection string, you can use IoT Hub Owner from shared access policies. 对于连接字符串,您可以从共享访问策略中使用IoT中心所有者。 If you want a more restrictive approach, make sure you select only registry read and write for this operation. 如果您想使用更严格的方法,请确保为此操作选择仅注册表读取和写入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM