Azure-cli: az login hangs on WSL

Created on 23 Jul 2020  路  6Comments  路  Source: Azure/azure-cli

Describe the bug

Running az login hangs, no output is shown. This is on Debian 10 over WSL on Windows 1809.

Running az login --debug logs the following link, opening manually and logging in works fine.
Open browser with url: https://login.microsoftonline.com/common/oauth2/authorize?....

Command Name
az login

Errors:
None

To Reproduce:

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

  • az login

Expected Behavior

The browser opens.

Environment Summary

Linux-4.4.0-17763-Microsoft-x86_64-with-debian-10.4
Python 3.6.10
Installer: DEB

azure-cli 2.9.1

Additional Context


Account OKR3.2 Candidate

Most helpful comment

I'll use az login --use-device-code as that also works. I'm good to close this issue provided we get the change from #14505.

Thank you

All 6 comments

add to S174

I tried Debian WSL on Microsoft Store but couldn't repro.

image

The code for opening a browser is at

https://github.com/Azure/azure-cli/blob/04210197837bbceb547f86df7f086a42c96e0d2a/src/azure-cli-core/azure/cli/core/util.py#L526

Does it work if you run powershell.exe in WSL? It should print something like

$ powershell.exe
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS Microsoft.PowerShell.Core\FileSystem::\\wsl$\Debian\home\user3>

But indeed, the current az login process for auth code flow gives too little information and sometimes leads to confusion, as discussed in https://github.com/MicrosoftDocs/azure-docs-cli/issues/2093.

@jiasli Running this spins up the loading icon on the mouse for about half a second, and then nothing happens.

gtaillon@debian:/mnt/c/Users/gtaillon$ powershell.exe -Command Start-Process "https://google.com"
gtaillon@debian:/mnt/c/Users/gtaillon$ which powershell.exe
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe

However this works (from https://github.com/PowerShell/PowerShell/issues/5715#issuecomment-400857048):

[System.Diagnostics.Process]::Start([System.Diagnostics.ProcessStartInfo] @{ FileName = 'http://example.org'; UseShellExecute = $True })

That powershell is 5.1.17763.x

Thanks for the information. However, I still can't reproduce it in Debian WSL.

In WSL:

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

$ powershell.exe -Command Start-Process "https://google.com"

In powershell.exe:

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Could you update the Windows system to 1909 or 2004 and try again?

More context: I switched from using cmd.exe to powershell.exe in https://github.com/Azure/azure-cli/pull/12851, because cmd.exe doesn't work with UNC paths (https://github.com/Azure/azure-cli/issues/11927).

If you don't want to update Windows and powershell.exe, you may use az login --use-device-code as a workaround.

I'll use az login --use-device-code as that also works. I'm good to close this issue provided we get the change from #14505.

Thank you

Was this page helpful?
0 / 5 - 0 ratings