Azure_IoT_Central_ESP32 SDK [ERROR] Device provisisioning failed.

Dave Frenk 21 Reputation points
2024-09-10T14:22:45.82+00:00

This has been a recurring issue with this SDK. I've double/triple checked all the parameters regarding the deviceID, template DTMI, and DPS provisioning ID are correct. I'm using the SAS primary key from a Device Connection Group I created in IOTC. This key is used to generate a token in the Azure CLI prompt with the following command:

az iot central device compute-device-key --primary-key <enrollment group primary key> --device-id <device ID>

Here is the log generated running the code in Arduino:

1970/1/1 00:00:01 [INFO] WiFi connected, IP address: 192.168.40.73

1970/1/1 00:00:01 [INFO] Setting time using SNTP

........

2024/9/10 14:11:14 [INFO] Time initialized!

2024/9/10 14:11:14 [INFO] Azure IoT client initialized (state=2)

2024/9/10 14:11:15 [INFO] MQTT client target uri set to 'mqtts://global.azure-devices-provisioning.net'

2024/9/10 14:11:15 [INFO] MQTT client connecting.

2024/9/10 14:11:16 [INFO] MQTT client connected (session_present=0).

2024/9/10 14:11:16 [INFO] MQTT client subscribing to '$dps/registrations/res/#'

2024/9/10 14:11:16 [INFO] MQTT topic subscribed (message id=12954).

2024/9/10 14:11:16 [INFO] MQTT client publishing to '$dps/registrations/PUT/iotdps-register/?$rid=1'

2024/9/10 14:11:16 [INFO] MQTT message received.

2024/9/10 14:11:16 [ERROR] Device provisisioning failed.

2024/9/10 14:11:16 [ERROR] Azure IoT client is in error state.

2024/9/10 14:11:16 [INFO] MQTT client being disconnected. EDIT:

Discovered the issue, i had brackets around the primary key and device ID for this statement to get the SAS tokens.

az iot central device compute-device-key --pk primary-key-here --device-id device-ID-here

Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
364 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sander van de Velde | MVP 33,146 Reputation points MVP
    2024-09-10T17:12:05.3633333+00:00

    Hello Dave Frenk,

    welcome to this moderated Azure community forum.

    If you want to connect an Azure IoT Central device you need to provide information like what you see in the device connect information dialog:

    User's image

    Please check if the information from the command looks like what the IoT portal dialog shows.

    Then, try to connect with the portal dialog information first.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.