0

I am using IoT Central and I am provisioning a new device with Microsoft.Azure.Devices.Client.ProvisioningDeviceClient() and I cant find a way to set the Device Name at the same time and it is defaulting to the Device ID.

The Parameters are:

PropaneTank_DPS": {
    "ModelId": "Model ID",
    "DeviceSecurityType": "dps",
    "DpsIdScope": "ID scope",
    "DeviceId": "test-device1-i90",
    "DeviceSymmetricKey": "device symmetric key",
    "DpsEndpoint": "global.azure-devices-provisioning.net",
    "DeviceName": "Test Device 1 - I90"
  }

The device gets provisioned but the Device Name that shows up in IoT Central is "test-device1-i90". Is there a way to set this at provision time? If not, is there an API I can change it since it is not part of the devices properties?

Mike Lenart
  • 767
  • 1
  • 5
  • 19

1 Answers1

0

have a look at the Device - Update reference

the following is my example:

enter image description here

Note, that the IoT Central ApiToken is used for Authorization header.

Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • Do you know how to do this with the SDKs? – Mike Lenart Aug 15 '22 at 07:50
  • There is no SDK for Azure IoT Central. Using the REST APIs with an ApiToken authorization is straightforward call. – Roman Kiss Aug 15 '22 at 08:20
  • I am using the IoT Hub and Device Provisioning SDKs and not the APIs. – Mike Lenart Aug 15 '22 at 23:38
  • You can't set the device name that's displayed in IoT Central using the Device Provisioning SDKs. The device name is managed by IoT Central - as @RomanKiss says, you need to use the IoT Central REST API to set the device name. – Dominic Betts Aug 22 '22 at 10:56
  • @DominicBetts is there a good c# example code on GitHub that does this that you know about? – Mike Lenart Aug 29 '22 at 01:06
  • @MikeLenart - I'm not aware of a C# sample that shows how to add a device registration to IoT Central. You can learn how to use the REST API here: https://learn.microsoft.com/en-us/azure/iot-central/core/howto-manage-devices-with-rest-api#add-a-device, and there's a sample Postman file that shows it in action here: https://raw.githubusercontent.com/Azure-Samples/iot-central-docs-samples/main/postman-collection/IoT%20Central.postman_collection.json. If you do a search, there are lots of examples that show how to make a REST API call from C#. – Dominic Betts Aug 30 '22 at 05:48