Skip to content

az login fails: OSError: [WinError 0] #20278

@Remi-Faydide

Description

@Remi-Faydide

Azure CLI multiple issues after update to 2.30.0

Describe the bug

Command tested without success

  • az apim api versionset list
  • az ad signed-in-user show
  • az ad sp list
  • az group list
  • az login
  • ...

Errors

The command failed with an unexpected error. Here is the traceback:
[WinError 0] : ''
Traceback (most recent call last):
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\knack\cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 657, in execute
    raise ex
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\command_operation.py", line 112, in handler
    client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\command_modules\apim\_client_factory.py", line 10, in cf_apim
    return get_mgmt_service_client(cli_ctx, ApiManagementClient)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\client_factory.py", line 70, in get_mgmt_service_client
    client, _ = _get_mgmt_service_client(cli_ctx, client_type, subscription_id=subscription_id,
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\commands\client_factory.py", line 212, in _get_mgmt_service_client
    cred, subscription_id, _ = profile.get_login_credentials(subscription_id=subscription_id, resource=resource,
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\_profile.py", line 335, in get_login_credentials
    credential = self._create_credential(account, client_id=client_id)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\_profile.py", line 588, in _create_credential
    return identity.get_user_credential(username_or_sp_id)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\auth\identity.py", line 182, in get_user_credential
    return UserCredential(self.client_id, username, **self._msal_app_kwargs)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\azure\cli\core\auth\msal_authentication.py", line 41, in __init__
    accounts = self.get_accounts(username)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\msal\application.py", line 930, in get_accounts
    accounts = self._find_msal_accounts(environment=self.authority.instance)
  File "C:\Users\{username}\AppData\Roaming\Python\Python39\site-packages\msal\application.py", line 968, in _find_msal_accounts
    for a in self.token_cache.find(
  File "C:\Python39\lib\site-packages\msal_extensions\token_cache.py", line 54, in find
    self._reload_if_necessary()
  File "C:\Python39\lib\site-packages\msal_extensions\token_cache.py", line 35, in _reload_if_necessary
    self.deserialize(self._persistence.load())
  File "C:\Python39\lib\site-packages\msal_extensions\persistence.py", line 172, in load
    return self._dp_agent.unprotect(data)
  File "C:\Python39\lib\site-packages\msal_extensions\windows.py", line 111, in unprotect
    raise OSError(256, '', '', err_code)
OSError: [WinError 0] : ''

To Reproduce

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  1. Update to the latest azure cli: pip install azure-cli --user --upgrade
  2. try one of the following commands
    • az apim api versionset list --resource-group {} --service-name {} --subscription {}
    • az login ==> nothing happens
    • all the commands listed previously fails with the same errors

Expected Behavior

No errors when launching such commands

Environment Summary

Windows-10-10.0.19043-SP0, 
Python 3.9.5
Installer: PIP

azure-cli 2.30.0

Extensions:
account 0.2.1
ad 0.1.0
aks-preview 0.5.26
azure-devops 0.20.0
portal 0.1.2
ssh 0.1.5
subscription 0.1.4

Additional Context

I installed the previous version 2.29.2 with the command pip install azure-cli==2.29.2 --user but now when I try to launch my az commands, I have a footer on each commands

New Azure CLI version available. Running 'az upgrade' to update automatically.
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Your current Azure CLI version is 2.29.2. Latest version available is 2.30.0.
Please check the release notes first: https://docs.microsoft.com/cli/azure/release-notes-azure-cli
Do you want to continue? (Y/n):

Despite this is quite annoying to say no each time, my Terraform commands don't work since it tries to parse the last sentence Do you want to continue? (Y/n):

Error parsing json result from the Azure CLI: Error unmarshaling the result of Azure CLI: invalid character 'D' looking for beginning of value.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions