In my case this thread helped me
Unable to Register Devices Using DPS Enrollment Group (401 Unauthorized)
We are encountering issues while attempting to register devices using an enrollment group in Azure IoT Device Provisioning Service (DPS) with symmetric key authentication. Despite following all the documented steps, the device registration fails with an HTTP 401 Unauthorized error (errorCode: 401002
).
Here’s a summary of our setup and the steps taken:
DPS Configuration:
- Attestation Mechanism: Symmetric Key.
- Status: Enabled.
php Copy code SharedAccessSignature sr=<resourceUri>&sig=<generatedSignature>&se=<expiry>- Registration ID is explicitly set in the curl request and aligns with the enrollment group settings. **Steps Taken**: - Generated a SAS token using the primary key and the following formula:
php Copy code SharedAccessSignature sr=<scope>/registrations/<registrationId>&sig=<signature>&se=<expiry>Example SAS Token:
- Used curl to send a PUT request to: ``` bash Copy code https://global.azure-devices-provisioning.net/<scope>/registrations/<registrationId>/register?api-version=2019-03-31 ``` - Headers included: - `Content-Type: application/json` - `Authorization: SharedAccessSignature sr=<resourceUri>&sig=<generatedSignature>&se=<expiry>` - Payload: ``` json Copy code {"registrationId": ``` **Observed Behavior**: - The DPS endpoint resolves successfully, and the request is sent without connection issues. - However, the response is consistently: ``` json Copy code { ``` **Troubleshooting Steps**: - Verified network connectivity to `global.azure-devices-provisioning.net`. - Confirmed the primary key and registration ID are correct. - Regenerated the primary key and retried the process. - Used multiple tools (curl, PowerShell) for manual testing. - Verified that the enrollment group settings in DPS are correctly configured. - Referenced Azure documentation and community forums for guidance. ```---
Request for Support
- Can you help identify why the registration is failing with
401 Unauthorized
? - Are there additional configuration steps or settings that we may have overlooked?
- Could you assist in analyzing the issue using the
trackingId
provided in the error response?
We can provide additional logs or screenshots as needed. Thank you!We are encountering issues while attempting to register devices using an enrollment group in Azure IoT Device Provisioning Service (DPS) with symmetric key authentication. Despite following all the documented steps, the device registration fails with an HTTP 401 Unauthorized error (errorCode: 401002
).
Here’s a summary of our setup and the steps taken:
DPS Configuration:
- Attestation Mechanism: Symmetric Key.
- Status: Enabled.
php Copy code SharedAccessSignature sr=<resourceUri>&sig=<generatedSignature>&se=<expiry>- Registration ID is explicitly set in the curl request and aligns with the enrollment group settings. **Steps Taken**: - Generated a SAS token using the primary key and the following formula:
php Copy code SharedAccessSignature sr=<scope>/registrations/<registrationId>&sig=<signature>&se=<expiry>Example SAS Token:
- Used curl to send a PUT request to: ``` bash Copy code https://global.azure-devices-provisioning.net/<scope>/registrations/<registrationId>/register?api-version=2019-03-31 ``` - Headers included: - `Content-Type: application/json` - `Authorization: SharedAccessSignature sr=<resourceUri>&sig=<generatedSignature>&se=<expiry>` - Payload: ``` json Copy code {"registrationId": ``` **Observed Behavior**: - The DPS endpoint resolves successfully, and the request is sent without connection issues. - However, the response is consistently: ``` json Copy code { ``` **Troubleshooting Steps**: - Verified network connectivity to `global.azure-devices-provisioning.net`. - Confirmed the primary key and registration ID are correct. - Regenerated the primary key and retried the process. - Used multiple tools (curl, PowerShell) for manual testing. - Verified that the enrollment group settings in DPS are correctly configured. - Referenced Azure documentation and community forums for guidance. ```---
Request for Support
- Can you help identify why the registration is failing with
401 Unauthorized
? - Are there additional configuration steps or settings that we may have overlooked?
- Could you assist in analyzing the issue using the
trackingId
provided in the error response?
We can provide additional logs or screenshots as needed. Thank you!
Azure IoT Hub
2 answers
Sort by: Most helpful
-
Vahid Ghafarpour 23,385 Reputation points Volunteer Moderator
2024-12-23T19:46:16.9866667+00:00 -
Sander van de Velde | MVP 36,766 Reputation points MVP Volunteer Moderator
2024-12-24T10:06:38.2766667+00:00 Hello Allen,
welcome to this moderated Azure community forum.
Please try the group enrollment first using a C# or Python application to prove the cloud part is set up correctly.
Check this blog post for an example about group enrollments. It uses Azure IoT Edge but this can be combined with this Python client example. That one comes with an individual DPS enrollment example but this would work for a group enrollment too.
Once this is set up correctly, you can try to connect your ESP32.
Apart from this NanoFramework example, I have no experience with these devices.
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.