Skip to content

AZ CLI using azure-iot extension TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource' #31042

@Wallemz

Description

@Wallemz

Describe the bug

Hello,

We've been running pipelines to manage Azure resources using the Azure CLI and the azure-iot extension. Since updating the Azure CLI to version 2.70.0, we've encountered the same issue described here. It appears that the azure-iot extension is using a deprecated authentication method that is no longer compatible with Azure CLI 2.70.0.

Related command

az iot du update import

Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/commands_update.py", line 135, in import_update
    data_manager = DeviceUpdateDataManager(
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/providers/base.py", line 236, in __init__
    self.data_client = self.get_data_client(self.container.account.host_name, instance_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/providers/base.py", line 93, in get_data_client
    credential=profile.get_login_credentials(resource=AUTH_RESOURCE_ID)[0],
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues

Issue script & Debug output

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
Traceback (most recent call last):
  File "/opt/az/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/commands_update.py", line 135, in import_update
    data_manager = DeviceUpdateDataManager(
                   ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/providers/base.py", line 236, in __init__
    self.data_client = self.get_data_client(self.container.account.host_name, instance_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/az/azcliextensions/azure-iot/azext_iot/deviceupdate/providers/base.py", line 93, in get_data_client
    credential=profile.get_login_credentials(resource=AUTH_RESOURCE_ID)[0],
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
##[error]2025-03-14 20:47:52 - The last command failed. Exiting the script.

##[error]Script failed with exit code: 1

Expected behavior

Azure Device Update imported successfully.

Environment Summary

azure-cli                         2.70.0

core                              2.70.0
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
azure-iot                         0.25.0

Dependencies:
msal                            1.31.2b1
azure-mgmt-resource               23.1.1

Python location '/opt/az/bin/python3'
Config directory '/home/vsts/.azure'
Extensions directory '/opt/az/azcliextensions'

Python (Linux) 3.12.8 (main, Feb 26 2025, 06:47:10) [GCC 11.4.0]

Additional context

The latest successful run was executed with the following configurations:

WARNING: You have 2 update(s) available. Consider updating your CLI installation with 'az upgrade'
azure-cli                         2.69.0 *

core                              2.69.0 *
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
azure-iot                         0.25.0

Dependencies:
msal                            1.31.2b1
azure-mgmt-resource               23.1.1

Python location '/opt/az/bin/python3'
Config directory '/home/vsts/.azure'
Extensions directory '/opt/az/azcliextensions'

Python (Linux) 3.12.8 (main, Feb  5 2025, 06:39:23) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botIoTIoT/CLIService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions