-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect-AzAccount - VSCode Remote-SSH - pwsh #24926
Comments
While this change would unlocks part of the problem for VSCode Remote-SSH there is still an issue where the local forwarding port 8400 just hangs. I think its because the VSCode Azure Account locally is running on port 8400, and VSCode Remote does not know what local ports are used. Azure CLI / python identity library has some code to make sure the port does not conflict. I think this would need to be different based on context. azure-powershell/src/Accounts/Authenticators/InteractiveUserAuthenticator.cs Lines 81 to 85 in 784c5e0
|
When it comes to conflicting local ports possibly from another Connect-AzAccount, then this is a related issue:
-- When it comes to the request hanging, I think it's because on the MSAL is listening on port 8400 on TCP6 only.
To mitigate locally setting this will force IPv4. export DOTNET_SYSTEM_NET_DISABLEIPV6=true
pwsh The localhost webserver is using hostname, which binds to ipv6 on my system. The solution is likely to support Ipv6 forwarding in vscode remote-ssh - microsoft/vscode-remote-release#7029 or change the redirect uri to use 0.0.0.0 which is what az login is doing. $server =[System.Net.HttpListener]::new()
$server.Prefixes.Add("http://localhost:8400/"
$server.Start()
# tcp6 0 0 ::1:8400 :::* LISTEN 2270420/pwsh
// Obviously this is expected to IPv4
$server =[System.Net.HttpListener]::new()
$server.Prefixes.Add("http://*:8400/"
$server.Start()
# tcp 0 0 0.0.0.0:8400 0.0.0.0:* LISTEN 2270420/pwsh
// Obviously this is expected to IPv4
$server =[System.Net.HttpListener]::new()
$server.Prefixes.Add("http://127.0.0.1:8400/"
$server.Start()
# tcp 0 0 127.0.0.1:8400 0.0.0.0:* LISTEN 2270420/pwsh
[System.Net.Dns]::GetHostByName("localhost")
HostName Aliases AddressList
-------- ------- -----------
localhost {} {::1, 127.0.0.1}
az login
# tcp 0 0 0.0.0.0:36957 0.0.0.0:* LISTEN 2281151/python3.9
# |
Description
When using
Connect-AzAccount
the following is produced:My setup is the following:
VSCode Remote-SSH will open
xdg-open
from the remote machine to my local machine browserI was able to track down the issue to this function which would return false in my case because there is no DISPLAY, this is a SSH connection.
azure-powershell/src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs
Lines 510 to 514 in 784c5e0
azure-powershell/src/Accounts/Authentication/Utilities/CommonUtilities.cs
Lines 28 to 36 in 784c5e0
I think these common utilities check could be remove and rely on Microsoft.Identity.Client exception throwing if its unable to open interactively.
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/f9253a67e69d4c34f30d26063006d6f788d71591/src/client/Microsoft.Identity.Client/Platforms/netcore/NetCorePlatformProxy.cs#L189-L228
A workaround is as simple as setting
$env:DISPLAY = ":0.0"
before runningConnect-AzAccount
. I just set this up in~/.config/powershell/profile.ps1
so it is always loaded.Issue script & Debug output
Environment data
Module versions
Error output
Technically no error was produced, just a warning and exits.
The text was updated successfully, but these errors were encountered: