Azure / Azure/azure-cli

az login does not work from inside devcontainer

Open
#29,265 3 comments 0 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad Auto-Assign Auto-Resolve Azure CLI Team customer-reported Possible-Solution question Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

When I install the azure CLI in my devcontainer and then run `az login`, the Browser opens
After I successfully sign in there to azure and go back to the terminal, I see the error message
```
The command failed with an unexpected error. Here is the traceback:
can only concatenate str (not "NoneType") to str
Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 664, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 731, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 701, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py", line 334, in __call__
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/custom.py", line 175, in login
selected = SubscriptionSelector(subscriptions)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 19, in __init__
self._format_subscription_table()
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 52, in _format_subscription_table
'Tenant': highlight_text(self._get_tenant_string(sub), is_default)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/profile/_subscription_selector.py", line 31, in highlight_text
return format_styled_text((Style.HIGHLIGHT, text)) if row_is_default else text
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/style.py", line 201, in format_styled_text
formatted_parts.append(escape_seq + raw_text)
~~~~~~~~~~~^~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
```

### Related command

`az login`

### Errors

see above

### Issue script & Debug output

Contains too much data I am not sure whether I can share here

### Expected behavior

The login works

### Environment Summary

{
"azure-cli": "2.61.0",
"azure-cli-core": "2.61.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {}
}

azure-cli 2.61.0

core 2.61.0
telemetry 1.1.0

Dependencies:
msal 1.28.0
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'
Extensions directory '/home/node/.azure/cliextensions'

Python (Linux) 3.11.8 (main, May 16 2024, 03:50:11) [GCC 10.2.1 20210110]

Legal docs and information: [aka.ms/AzureCliLegal](http://aka.ms/AzureCliLegal)

Your CLI is up-to-date.

Docker image: [mcr.microsoft.com/devcontainers/typescript-node:0-18](http://mcr.microsoft.com/devcontainers/typescript-node:0-18)

### 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.