Ricky
Ricky

Reputation: 1777

Get device connection strings from newly created Azure IoT device

Using Azure.Devices, after creating a new device in an IoT Hub using either AddDeviceWithTwinAsync or AddDeviceAzync, how can I get the primary or secondary connection string for the new device?

For context, I'm adding an API endpoint that will allow us to register (in azure iot hub and our inventory db) a device in a single call, and I want to return the connection string to the client so that it can set that connection string to the hardware device.

Upvotes: 0

Views: 646

Answers (1)

humblejay
humblejay

Reputation: 347

Use RegistryManager.GetDeviceAsync to get the device class, the authentication object will have the related key or certificate and then build the connection string.

A better option is to use Device Provisioning Service, it provides single global endpoint for devices and provision devices to IoThub based on latency, round robin, static mapping or custom logic.

Upvotes: 1

Related Questions