Azure-cli: az login fails

Created on 1 Apr 2020  路  6Comments  路  Source: Azure/azure-cli

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name
az login

Errors:

'displayName'
Traceback (most recent call last):
python3.6/site-packages/knack/cli.py, ln 215, in invoke
    cmd_result = self.invocation.execute(args)
cli/core/commands/__init__.py, ln 625, in execute
    raise ex
cli/core/commands/__init__.py, ln 689, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
cli/core/commands/__init__.py, ln 682, in _run_job
    six.reraise(*sys.exc_info())
lib/python3.6/site-packages/six.py, ln 693, in reraise
    raise value
...
azure/cli/core/_profile.py, ln 203, in find_subscriptions_on_login
    tenant, self._ad_resource_uri)
azure/cli/core/_profile.py, ln 844, in find_through_interactive_flow
    result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
azure/cli/core/_profile.py, ln 883, in _find_using_common_tenant
    t.display_name = t.additional_properties['displayName']
KeyError: 'displayName'

To Reproduce:

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

  • docker run -it mcr.microsoft.com/azure-cli:2.3.0
  • az login

Expected Behavior

Environment Summary

Linux-5.0.0-1035-azure-x86_64-with
Python 3.6.10
Installer: DOCKER

azure-cli 2.3.0

Additional Context


AAD

Most helpful comment

Hi @taoyama, thanks for reporting this issue. I can reproduce by using profiles other than latest. It fails with API https://management.azure.com/tenants?api-version=2016-06-01 because displayName is not present.

> az cloud update -n AzureCloud --profile 2017-03-09-profile
> az login
You have logged in. Now let us find all the subscriptions to which you have access...
The command failed with an unexpected error. Here is the traceback:

'displayName'
Traceback (most recent call last):
  File "d:\cli\knack\knack\cli.py", line 215, in invoke
    cmd_result = self.invocation.execute(args)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 625, in execute
    raise ex
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 689, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 682, in _run_job
    six.reraise(*sys.exc_info())
  File "D:\cli\env38\lib\site-packages\six.py", line 703, in reraise
    raise value
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 659, in _run_job
    result = cmd_copy(params)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 324, in __call__
    return self.handler(*args, **kwargs)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\__init__.py", line 531, in default_command_handler
    return op(**command_args)
  File "d:\cli\azure-cli\src\azure-cli\azure\cli\command_modules\profile\custom.py", line 142, in login
    subscriptions = profile.find_subscriptions_on_login(
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 195, in find_subscriptions_on_login
    subscriptions = subscription_finder.find_through_authorization_code_flow(
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 832, in find_through_authorization_code_flow
    result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 883, in _find_using_common_tenant
    t.display_name = t.additional_properties['displayName']
KeyError: 'displayName'

We will release a hotfix asap.

All 6 comments

It is not reproducible with docker run -it mcr.microsoft.com/azure-cli:2.1.0.

@jiasli please help take a look.

Hi @taoyama, thanks for reporting this issue. I can reproduce by using profiles other than latest. It fails with API https://management.azure.com/tenants?api-version=2016-06-01 because displayName is not present.

> az cloud update -n AzureCloud --profile 2017-03-09-profile
> az login
You have logged in. Now let us find all the subscriptions to which you have access...
The command failed with an unexpected error. Here is the traceback:

'displayName'
Traceback (most recent call last):
  File "d:\cli\knack\knack\cli.py", line 215, in invoke
    cmd_result = self.invocation.execute(args)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 625, in execute
    raise ex
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 689, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 682, in _run_job
    six.reraise(*sys.exc_info())
  File "D:\cli\env38\lib\site-packages\six.py", line 703, in reraise
    raise value
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 659, in _run_job
    result = cmd_copy(params)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 324, in __call__
    return self.handler(*args, **kwargs)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\__init__.py", line 531, in default_command_handler
    return op(**command_args)
  File "d:\cli\azure-cli\src\azure-cli\azure\cli\command_modules\profile\custom.py", line 142, in login
    subscriptions = profile.find_subscriptions_on_login(
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 195, in find_subscriptions_on_login
    subscriptions = subscription_finder.find_through_authorization_code_flow(
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 832, in find_through_authorization_code_flow
    result = self._find_using_common_tenant(token_entry[_ACCESS_TOKEN], resource)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\_profile.py", line 883, in _find_using_common_tenant
    t.display_name = t.additional_properties['displayName']
KeyError: 'displayName'

We will release a hotfix asap.

add to S168

We have release 2.3.1 and fixed this issue. Please update the installed Azure CLI and give it a try!

Thanks for the quick fix!

I've confirmed I can login with 2.3.1.

$ docker run -it mcr.microsoft.com/azure-cli:2.3.1
# az login
Was this page helpful?
0 / 5 - 0 ratings