I've got a connectionString from a third party to Microsoft Azure IoT Hub which doesn't contain a DeviceId
.
I've tried to use this SDK, but it requires a DeviceId
: https://www.npmjs.com/package/azure-iot-device-http
Can one use Azure IoT Hub without DeviceId
?
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.
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
hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.