azure-iot-sdk-python icon indicating copy to clipboard operation
azure-iot-sdk-python copied to clipboard

Error occured with IoT Hub F1 tier for provision symmetric key group sample.

Open renakim opened this issue 3 years ago • 5 comments

Context

  • OS and version used: Windows 10
  • Python version: 3.9.11
  • pip version: 22.2
  • list of installed packages: azure-iot-device==2.11.0
  • cloned repo: azure-iot-sdk-python (60535b5554f9da409fc26c162b54a3d230004e4e)

Description of the issue

I'm using the below resources.

  • IoT Hub: F1, S1 tier
  • DPS: S1

When I test a provisioning sample(provision_symmetric_key_group.py), get an error at the F1 tier IoT Hub.

But once I try with another IoT Hub in the S1 tier for the same process, it works fine.

According to the guide document below, it seems that the provisioning function is available in F1 tier, please check it.

  • https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-scaling#basic-and-standard-tiers

Code sample exhibiting the issue

  • https://github.com/Azure/azure-iot-sdk-python/blob/main/samples/sync-samples/provision_symmetric_key_group.py

Console log of the issue

The error log is as below.

$ python provision_symmetric_key_group.py 
register_device() prov-device-01
Traceback (most recent call last):
  File "C:\Users\Rena\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\iot\device\provisioning\provisioning_device_client.py", line 25, in handle_result
    return callback.wait_for_completion()
  File "C:\Users\Rena\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\iot\device\common\evented_callback.py", line 69, in wait_for_completion
    raise self.exception
azure.iot.device.exceptions.ServiceError: Query Status operation returned a failed registration status with a status code of 200

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\azure-iot-sdk-python\samples\sync-samples\provision_symmetric_key_group.py", line 81, in <module>
    registration_result = register_device(registration_id=device_id)
  File "D:\azure-iot-sdk-python\samples\sync-samples\provision_symmetric_key_group.py", line 75, in register_device
    return provisioning_device_client.register()
  File "C:\Users\Rena\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\iot\device\provisioning\provisioning_device_client.py", line 83, in register
    result = handle_result(register_complete)
  File "C:\Users\Rena\AppData\Local\Programs\Python\Python39\lib\site-packages\azure\iot\device\provisioning\provisioning_device_client.py", line 41, in handle_result
    raise exceptions.ClientError("Unexpected failure") from e
azure.iot.device.exceptions.ClientError: Unexpected failure

renakim avatar Aug 10 '22 00:08 renakim

What are the differences between the 2 hubs that you are using ?

olivakar avatar Aug 10 '22 20:08 olivakar

What are the differences between the 2 hubs that you are using ?

I mentioned it in the text. One is the F1 tier and one is the S1 tier. The DPS used for provisioning is the S1 tier. image

renakim avatar Aug 10 '22 22:08 renakim

I tried the sample with an associated F1 tier IoT Hub without any issues. Can you share your DPS name and registration id in a safer way via email?

olivakar avatar Aug 11 '22 19:08 olivakar

Yes, I will share the information. Based on what you said, it seems to be a DPS problem, so I tested it with another DPS and it worked fine. Could I use an email address in your profile?

renakim avatar Aug 11 '22 23:08 renakim

yes you can use the email address on my profile

olivakar avatar Aug 12 '22 22:08 olivakar

@renakim I checked the service logs and the only reason that your group sample might have failed with that specific DPS was due to the token validation failing. This is the exact message I saw in one of the logs. "message": SymmetricKeyAttestation SasToken validation failed as no matching enrollmentGroup was found for registration id <SOMETHING>,

olivakar avatar Aug 18 '22 00:08 olivakar

The cause of the problem was that the deleted hub was set up on the DPS Linked IoT Hub. I re-established the connection and tested it and it works. @olivakar Thank you for your help.

renakim avatar Aug 18 '22 23:08 renakim

To clarify the above error for token validation failing was not the cause. This was in the logs of a working DPS with F1 IoT Hub. The DPS that did not work was a different one and the message in the logs was An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: 'SOMETHING.azure-devices.net' which points to it being that the hub was deleted or changed etc.

olivakar avatar Aug 19 '22 16:08 olivakar