Azure/azure-iot-cli-extension

Az CLI fails when trying to create an IoT Edge deployment

foreverstupid opened this issue · 4 comments

Unable to create deployment for IoT Edge due to the internal error

Command Name
az iot edge deployment create Extension Name: azure-iot. Version: 0.10.6.

Errors:

The command failed with an unexpected error. Here is the traceback:
'IotHubResourceOperations' object has no attribute 'config'
Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 657, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 691, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 328, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "C:\Users\nikol\.azure\cliextensions\azure-iot\azext_iot\operations\hub.py", line 1002, in iot_edge_deployment_create
    return _iot_hub_configuration_create(
  File "C:\Users\nikol\.azure\cliextensions\azure-iot\azext_iot\operations\hub.py", line 1064, in _iot_hub_configuration_create
    target = discovery.get_target(
  File "C:\Users\nikol\.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 "C:\Users\nikol\.azure\cliextensions\azure-iot\azext_iot\iothub\providers\discovery.py", line 72, in find_iothub
    self._initialize_client()
  File "C:\Users\nikol\.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.

  • az iot edge deployment create -n {} -k {} -d {}

Expected Behavior

A new deployment has been created according to the deployment manifest.

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: MSI

azure-cli 2.24.0

Extensions:
azure-iot 0.10.6

Additional Context

The problem has been occured after Az CLI upgrade. Moreover, the same problem appeared in release pipelines of Azure DevOps.

@foreverstupid please try upgrading your IoT extension to v0.10.11 or greater (you could use the command az extension update --name azure-iot. The root cause is a breaking change from an SDK update in Azure CLI 2.24.0.

@foreverstupid please try upgrading your IoT extension to v0.10.11 or greater (you could use the command az extension update --name azure-iot. The root cause is a breaking change from an SDK update in Azure CLI 2.24.0.

Thanks for a quick reply. And what should I do to fix the same problem in Azure DevOps pipelines? Can I somehow specify the version of such an extension there?

You are talking about the AzureIoTEdgeV2 deployment task right? Looking at the code, there appears to be a path to use for a workaround, which is to pre-install the target azure-iot CLI extension version prior to running the deploy task. The logic should avoid installing azure-iot if its already there.

Thank you