Azure / azure-iot-cli-extension

Azure IoT extension for Azure CLI
Other
83 stars 65 forks source link

Failure to create new IoT Edge device #554

Closed contre closed 2 years ago

contre commented 2 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

While attempting to follow this Quickstart using the Cloud shell, I get the following error when attempting to create an IoT Edge device.

Command Name az iot hub device-identity create Extension Name: azure-iot. Version: 0.10.2.

Errors:

The command failed with an unexpected error. Here is the traceback:
'IotHubResourceOperations' object has no attribute 'config'
Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/richard/.azure/cliextensions/azure-iot/azext_iot/operations/hub.py", line 137, in iot_device_create
    target = discovery.get_target(
  File "/home/richard/.azure/cliextensions/azure-iot/azext_iot/iothub/providers/discovery.py", line 136, in get_target
    target_iothub = self.find_iothub(hub_name=hub_name, rg=rg)
  File "/home/richard/.azure/cliextensions/azure-iot/azext_iot/iothub/providers/discovery.py", line 72, in find_iothub
    self._initialize_client()
  File "/home/richard/.azure/cliextensions/azure-iot/azext_iot/iothub/providers/discovery.py", line 35, in _initialize_client
    self.sub_id = self.client.config.subscription_id
AttributeError: 'IotHubResourceOperations' object has no attribute 'config'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Environment Summary

Linux-5.4.0-1086-azure-x86_64-with-glibc2.28 (Cloud Shell), Common Base Linux Delridge (quinault)
Python 3.10.5
Installer: DEB

azure-cli 2.38.0

Extensions:
azure-iot 0.10.2
ai-examples 0.2.5
ssh 1.1.2

Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1

Additional Context

ghost commented 2 years ago

Thanks for submitting an issue, @contre. I noticed your issue contains the following error:

'IotHubResourceOperations' object has no attribute 'config' which likely stems from a breaking change introduced in newer CLI core releases (2.24+) that affects users with older extension versions.

Please try upgrading your CLI extension to a newer version (fixed in 0.10.11+) and see if that resolves the issue: az extension update --name azure-iot

contre commented 2 years ago

Solved by the suggested command. This was unexpected as I was using the Cloud Shell at the time.