Azure CLI - Error on az login : 'dict' object has no attribute 'append'

58 Views Asked by At

Azure CLI for Windows : I had been struggling with this error from few weeks, that occurred everytime I ran az login.

I have found a solution, so I thought of publishing it here. I had come across another thread where somebody was running into same situation without a fix.

The command failed with an unexpected error. Here is the traceback:
'dict' object has no attribute 'append'
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 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/profile/custom.py", line 139, in login
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 154, in login
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/identity.py", line 153, in login_with_auth_code
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/identity.py", line 112, in _msal_app
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/identity.py", line 95, in _msal_app_kwargs
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/identity.py", line 122, in _load_msal_http_cache
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/binary_cache.py", line 28, in __init__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/binary_cache.py", line 44, in load
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/decorators.py", line 102, in _wrapped_func
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/binary_cache.py", line 35, in _load
AttributeError: 'dict' object has no attribute 'append'

I tried :

  • uninstalling and reinstalling Azure CLI
  • Installing latest and little older versions of Azure CLI
  • uninstalling all Python versions from my computer and then installing CLI alone
  • Installing Python 3.10 (which appears to be highest supported version) and then installing Azure CLI
  • Reboots

All I needed was a login page from azure CLI and a token back.

But to no avail. I kept running into this same error.

In the end, a basic step worked, i.e. to clean the azure cli's working directory.

Its not a "solution" kind of solution, but one that bugged me a lot and forced me to rely on VMs to do my automation tasks. Also, if you lookup this error, you'll only find answers asking you to fix your Python code (unrelated to Azure CLI)

So Here's all you need to do -

Locate and Delete this folder on your computer

%userprofile%\.azure or you can also use C:\Users\<Your username>\.azure

Once deleted, you can try az login in any CMD/Powershell and it will work.

1

There are 1 best solutions below

0
Arun Sharma On BEST ANSWER

Here's all you need to do to fix this -

Locate and Delete this folder on your computer

%userprofile%\.azure or you can also use C:\Users\<Your username>\.azure

Once deleted, you can try az login in any CMD/Powershell and it will work!