azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az quantum job list - unexpected error: TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

Open aiphasolutions opened this issue 11 months ago • 6 comments

Describe the bug

Hello I haven't found any issue for this issue, but I cannot list any jobs, it seems the package is calling a wrong parameter that is no longer supported in the Profile class.

az quantum job list -g MyResourceGroup -w MyWorkspace -l MyLocation

will give me this error

on the other hand this command works perfectly:

az quantum workspace delete -g MyResourceGroup -w MyWorkspace

Update while writing this issue: I identified the issue and will post it in the comments

Related command

az quantum job list -g MyResourceGroup -w MyWorkspace -l MyLocation

Errors

The command failed with an unexpected error. Here is the traceback: Profile.get_login_credentials() got an unexpected keyword argument 'resource' Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/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/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler return op(**command_args) ^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/operations/job.py", line 53, in list client = cf_jobs(cmd.cli_ctx, info.subscription, info.resource_group, info.name, info.location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 77, in cf_jobs return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).jobs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 67, in cf_quantum creds = _get_data_credentials(cli_ctx, subscription_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username /.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 31, in _get_data_credentials creds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

Issue script & Debug output

cli.knack.cli: Command arguments: [.....] cli.knack.cli: init debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x10047f240>, <function OutputProducer.on_global_arguments at 0x1006b6520>, <function CLIQuery.on_global_arguments at 0x1006efce0>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'quantum': ['azext_quantum'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: quantum 0.190 6 25 /Users/username/.azure/cliextensions/quantum cli.azure.cli.core: Total (1) 0.190 6 25
cli.azure.cli.core: Loaded 6 groups, 25 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : quantum job list cli.azure.cli.core: Command table: quantum job list cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x101b722a0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/username/.azure/commands/2025-03-04.20-37-50.quantum_job_list.34995.log'. az_command_data_logger: command args: quantum job list -g {} -w {} -l {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x101be5d00>] cli.knack.commands: Configured default 'AzureQuantum' for arg resource_group_name cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x101be5da0>, <function register_cache_arguments..add_cache_arguments at 0x101be5ee0>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x101be5f80>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1006b65c0>, <function CLIQuery.handle_query_parameter at 0x1006efd80>, <function register_ids_argument..parse_ids_arguments at 0x101be5e40>] az_command_data_logger: extension name: quantum az_command_data_logger: extension version: 1.0.0b4 Command group 'quantum' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus cli.azure.cli.core.azclierror: Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/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/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler return op(**command_args) ^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/operations/job.py", line 53, in list client = cf_jobs(cmd.cli_ctx, info.subscription, info.resource_group, info.name, info.location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 77, in cf_jobs return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).jobs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 67, in cf_quantum creds = _get_data_credentials(cli_ctx, subscription_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 31, in _get_data_credentials creds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback: az_command_data_logger: The command failed with an unexpected error. Here is the traceback: cli.azure.cli.core.azclierror: Profile.get_login_credentials() got an unexpected keyword argument 'resource' Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/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/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler return op(**command_args) ^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/operations/job.py", line 53, in list client = cf_jobs(cmd.cli_ctx, info.subscription, info.resource_group, info.name, info.location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 77, in cf_jobs return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).jobs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 67, in cf_quantum creds = _get_data_credentials(cli_ctx, subscription_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 31, in _get_data_credentials creds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource' az_command_data_logger: Profile.get_login_credentials() got an unexpected keyword argument 'resource' Traceback (most recent call last): File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 666, in execute raise ex File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/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/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job result = cmd_copy(params) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/init.py", line 336, in call return self.handler(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler return op(**command_args) ^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/operations/job.py", line 53, in list client = cf_jobs(cmd.cli_ctx, info.subscription, info.resource_group, info.name, info.location) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 77, in cf_jobs return cf_quantum(cli_ctx, subscription_id, resource_group_name, workspace_name, location).jobs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 67, in cf_quantum creds = _get_data_credentials(cli_ctx, subscription_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/username/.azure/cliextensions/quantum/azext_quantum/_client_factory.py", line 31, in _get_data_credentials creds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

Expected behavior

showing result

Environment Summary

azure-cli 2.70.0

core 2.70.0 telemetry 1.1.0

Extensions: quantum 1.0.0b4

Dependencies: msal 1.31.2b1 azure-mgmt-resource 23.1.1

Python location '/opt/homebrew/Cellar/azure-cli/2.70.0/libexec/bin/python' Config directory '/Users/username/.azure' Extensions directory '/Users/username/.azure/cliextensions'

Python (Darwin) 3.12.9 (main, Feb 4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

aiphasolutions avatar Mar 04 '25 19:03 aiphasolutions

Quick Fix for Azure Quantum CLI Extension Problem When running az quantum job commands with Azure CLI 2.70.0 or newer, you may encounter this error: CopyTypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource' This issue occurs because the Quantum extension (version 1.0.0b4) uses a deprecated authentication method that is no longer compatible with newer versions of the Azure CLI. Solution

Locate the extension's client factory file: Copy~/.azure/cliextensions/quantum/azext_quantum/_client_factory.py

Edit this file with your preferred text editor: bashCopynano ~/.azure/cliextensions/quantum/azext_quantum/_client_factory.py

Find the _get_data_credentials function (around line 31) with this line: pythonCopycreds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com")

Remove the resource parameter, changing it to: pythonCopycreds, _, _ = profile.get_login_credentials(subscription_id=subscription_id)

Save the file and exit the editor. The az quantum job commands should now work correctly.

Notes

This is a temporary fix until the extension is updated by the Azure team The patch may need to be reapplied if you update or reinstall the quantum extension This issue affects Azure CLI 2.70.0 and newer versions

aiphasolutions avatar Mar 04 '25 19:03 aiphasolutions

route to service team

yonzhan avatar Mar 04 '25 23:03 yonzhan

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ricardo-espinoza.

Track 1 Azure Python SDK support has been dropped in Azure CLI 2.70.0 (https://github.com/Azure/azure-cli/issues/30951).

quantum extension was migrated to Track 2 SDK in https://github.com/Azure/azure-cli-extensions/pull/3606, but it incorrectly calls profile.get_login_credentials() with resource="https://quantum.microsoft.com" which is for Track 1 SDK:

https://github.com/Azure/azure-cli-extensions/blob/80e1ed41c8b60b2bef5160b928a1120946173fd7/src/quantum/azext_quantum/_client_factory.py#L31

    creds, _, _ = profile.get_login_credentials(subscription_id=subscription_id, resource="https://quantum.microsoft.com")

The correct way is to pass scopes as credential_scopes while creating QuantumClient:

https://github.com/Azure/azure-cli-extensions/blob/80e1ed41c8b60b2bef5160b928a1120946173fd7/src/quantum/azext_quantum/_client_factory.py#L68

    client = QuantumClient(creds, subscription_id, resource_group_name, workspace_name, base_url=base_url(location), user_agent=get_appid())

https://github.com/Azure/azure-cli-extensions/blob/9416c8bc24a32864a08b7e6c6fb26cd4d3dad689/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_configuration.py#L63

        self.credential_scopes = kwargs.pop('credential_scopes', ['https://quantum.microsoft.com/.default'])

https://github.com/Azure/azure-cli/pull/29631 contains some real example PRs for this change.

jiasli avatar Mar 05 '25 09:03 jiasli

A current PR contains the fix:

I encountered this problem on 3/3/2025 and incorporated the fix for it into CLI PR 8197, which is currently awaiting review and merge.

We plan to release a new version of the Quantum CLI Extension soon.

warren-jones avatar Mar 05 '25 18:03 warren-jones

PR 8197 is merged, issue should be resolved.

A current PR contains the fix:

I encountered this problem on 3/3/2025 and incorporated the fix for it into CLI PR 8197, which is currently awaiting review and merge.

We plan to release a new version of the Quantum CLI Extension soon.

Bradben avatar Jun 05 '25 21:06 Bradben