Azure / Azure/azure-cli

azext_applicationinsights unexpected error: TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'

Open
#31,748 4 comments 1 reaction 1 assignee Claimed by @jsntcy View on GitHub
act-observability-squad Auto-Assign Auto-Resolve Azure CLI Team customer-reported Monitor question Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I found a similar issue https://github.com/Azure/azure-cli/issues/30947, but it seems that it wasn't fixed everywhere.

I have a PowerShell script that I'm running once in a quarter, and last quarter, everything worked fine.

I tried to run the script twice on different CLI versions, 2.70.0, and the latest

### Related command

az monitor app-insights query --resource-group "$resourceGroupName" --app "$appName" --analytics-query $query

### Errors

az : ERROR: The command failed with an unexpected error. Here is the traceback:
At line:1 char:1
+ az monitor app-insights query --resource-group "$resourceGroupName" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: The comm... the traceback::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

ERROR: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serial
ly
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 111, in handler
File "C:\Users\{username}\.azure\cliextensions\application-insights\azext_applicationinsights\_client_factory.py", line 12, in applicationinsights_
data_plane_client
cred, _, _ = profile.get_login_credentials(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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

az monitor app-insights query --resource-group "$resourceGroupName" --app "$appName" --analytics-query $query --debug
az : DEBUG: cli.knack.cli: Command arguments: ['monitor', 'app-insights', 'query', '--resource-group', '{resourceGroupName}', '--app', '{appName}'
, '--analytics-query', "let testNames = availabilityResults | summarize by name; availabilityResults | where name in (testNames) | summarize ['S
uccess Percent'] = strcat(tostring(round((countif(success == 1) * 100.0 / count()), 2)), '%'), ['Average Fail Duration'] = strcat(tostring(round
(avg(duration))), ' ms') by ['Test Name'] = name | union (availabilityResults | summarize ['Success Percent'] = strcat(tostring(round((countif(s
uccess == 1) * 100.0 / count()), 2)), '%'), ['Average Fail Duration'] = strcat(tostring(round(avg(duration))), ' ms') | extend ['Test Name'] = '
Overall') | sort by ['Success Percent'] asc", '--debug']
At line:1 char:1
+ az monitor app-insights query --resource-group "$resourceGroupName" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (DEBUG: cli.knac...sc", '--debug']:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

DEBUG: cli.knack.cli: __init__ debug log:
Cannot enable color.
DEBUG: cli.knack.cli: Event: Cli.PreExecute []
DEBUG: cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: cli.azure.cli.core: Modules found from index for 'monitor': ['azure.cli.command_modules.monitor', 'azext_applicationinsights']
DEBUG: cli.azure.cli.core: Loading command modules:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands
DEBUG: cli.azure.cli.core: monitor 0.688 22 68
DEBUG: cli.azure.cli.core: Total (1) 0.688 22 68
DEBUG: cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
DEBUG: cli.azure.cli.core: Loading extensions:
DEBUG: cli.azure.cli.core: Name Load Time Groups Commands Directory
DEBUG: cli.azure.cli.core: application-insights 0.094 12 36 C:\Users\{username}\.azure\cliextensions\application-insights
DEBUG: cli.azure.cli.core: Total (1) 0.094 12 36
DEBUG: cli.azure.cli.core: Loaded 33 groups, 104 commands.
DEBUG: cli.azure.cli.core: Found a match in the command table.
DEBUG: cli.azure.cli.core: Raw command : monitor app-insights query
DEBUG: cli.azure.cli.core: Command table: monitor app-insights query
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
DEBUG: cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\{username}\.azure\commands\2025-07-01.16-45-21.monitor
_app-insights_query.79516.log'.
INFO: az_command_data_logger: command args: monitor app-insights query --resource-group {} --app {} --analytics-query {} --debug
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_paramet
er at 0x00000256E9692340>]
INFO: cli.knack.commands: Configured default '{appName}' for arg resource_group_name
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x00000256E9
6923E0>, .add_cache_arguments at 0x00000256E9692520>, .update_breaking_change_info at 0x00000256E96925C0>]
DEBUG: cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
DEBUG: cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x00000256E9692480>]
INFO: az_command_data_logger: extension name: application-insights
INFO: az_command_data_logger: extension version: 1.2.0
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serial
ly
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 111, in handler
File "C:\Users\{username}\.azure\cliextensions\application-insights\azext_applicationinsights\_client_factory.py", line 12, in applicationinsights_
data_plane_client
cred, _, _ = profile.get_login_credentials(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
ERROR: cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
ERROR: az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
ERROR: cli.azure.cli.core.azclierror: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serial
ly
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 111, in handler
File "C:\Users\{username}\.azure\cliextensions\application-insights\azext_applicationinsights\_client_factory.py", line 12, in applicationinsights_
data_plane_client
cred, _, _ = profile.get_login_credentials(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
ERROR: az_command_data_logger: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serial
ly
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 111, in handler
File "C:\Users\{username}\.azure\cliextensions\application-insights\azext_applicationinsights\_client_factory.py", line 12, in applicationinsights_
data_plane_client
cred, _, _ = profile.get_login_credentials(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Profile.get_login_credentials() got an unexpected keyword argument 'resource'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
DEBUG: cli.knack.cli: Event: Cli.PostExecute []
INFO: az_command_data_logger: exit code: 1
INFO: cli.__main__: Command ran in 1.290 seconds (init: 0.344, invoke: 0.946)
INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
INFO: telemetry.client: Accumulated 0 events. Flush the clients.
INFO: telemetry.main: Finish splitting cli events and extra events, cli events: 1
INFO: telemetry.save: Save telemetry record of length 8161 in cache file under C:\Users\{username}\.azure\telemetry\20250701164522037
INFO: telemetry.main: Begin creating telemetry upload process.
INFO: telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\C
LI2\Lib\site-packages\azure\cli\telemetry\__init__.pyc C:\Users\{username}\.azure C:\Users\{username}\.azure\telemetry\20250701164522037"
INFO: telemetry.process: Return from creating process 55384
INFO: telemetry.main: Finish creating telemetry upload process.

### Expected behavior

Command executed without errors

### Environment Summary

azure-cli 2.74.0 *

core 2.74.0 *
telemetry 1.1.0

Extensions:
application-insights 1.2.0

Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\{username}\.azure'
Extensions directory 'C:\Users\{username}\.azure\cliextensions'

Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.