[英]Microsoft Azure IoT Hub and connectionString without DeviceId
I've got a connectionString from a third party to Microsoft Azure IoT Hub which doesn't contain a DeviceId
. 我有一个从第三方到Microsoft Azure IoT中心的connectionString,其中不包含
DeviceId
。
I've tried to use this SDK, but it requires a DeviceId
: https://www.npmjs.com/package/azure-iot-device-http 我尝试使用此SDK,但是它需要一个
DeviceId
: https : DeviceId
Can one use Azure IoT Hub without DeviceId
? 可以使用没有
DeviceId
Azure IoT中心吗?
Yes it should work as a IOT hub. 是的,它应该可以作为物联网中心。 Basically from the connection string which we get it from Azure portal doesn't include device id.
基本上,从我们从Azure门户获取的连接字符串中,不包括设备ID。
Sample for initializing a client and creation of device. 用于初始化客户端和创建设备的示例。
var iothub = require('azure-iothub');
var connectionString = '[IoT Connection String]';
var registry = iothub.Registry.fromConnectionString(connectionString);
// Create a new device
var device = {
deviceId: 'sample-device-' + Date.now()
};
registry.create(device, function(err, deviceInfo, res) {
if (err) console.log(op + ' error: ' + err.toString());
if (res) console.log(op + ' status: ' + res.statusCode + ' ' + res.statusMessage);
if (deviceInfo) console.log(op + ' device info: ' + JSON.stringify(deviceInfo));
});
You can find more samples here. 您可以在此处找到更多示例。
https://github.com/Azure/azure-iot-sdk-node/tree/master/service https://github.com/Azure/azure-iot-sdk-node/tree/master/service
hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.