Search code examples
azureazure-iot-sdk

Azure Device Provisioning through group enrollment using python


I have been trying to get the python sample from Azure/azure-iot-sdk-python "provision_x509.py" to connect through a group enrollment I created on my azure account, but I get the following error when trying to run the code:

Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\pipeline\pipeline_stages_base.py", line 102, in run_op self._run_op(op) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\pipeline\pipeline_thread.py", line 198, in wrapper return func(*args, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\pipeline\pipeline_stages_mqtt.py", line 127, in _run_op proxy_options=self.pipeline_root.pipeline_configuration.proxy_options, File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\mqtt_transport.py", line 133, in init self._mqtt_client = self._create_mqtt_client() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\mqtt_transport.py", line 169, in _create_mqtt_client ssl_context = self._create_ssl_context() File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\azure\iot\device\common\mqtt_transport.py", line 337, in _create_ssl_context self._x509_cert.pass_phrase,

FileNotFoundError: [Errno 2] No such file or directory SetMQTTConnectionArgsOperation: completing with error [Errno 2] No such file or directory SetProvisioningClientConnectionArgsOperation: completing with error [Errno 2] No such file or directory SetX509SecurityClientOperation: completing with error [Errno 2] No such file or directory Callback completed with error [Errno 2] No such file or directory NoneType: None

NOTE: I do create the env variables before calling the script.

I am using:

Python 3.7.5

azure-iot-device==2.1.1

azure-core==1.3.0


Solution

  • this error was caused by having the wrong paths to the certificates!