Azure / Azure/azure-powershell
Connect-AzAccount is hanging
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### Description
**Connect-AzAccount is hanging**
On issuing Connect-AzAccount, post verification of login, it stays hanging without any progress
I found out that with the latest version of The Az.Accounts, 2.8.0, running the following command:
**PS C:\Users\Administrator.AZS-DVM> Connect-AzAccount -Environment "AzureStackAdmin" -Debug -Verbose**
DEBUG: 9:23:53 AM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: 9:23:55 AM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 9:23:55 AM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 9:23:55 AM - Using Autosave scope 'CurrentUser'
Confirm
Are you sure you want to perform this action?
Performing the operation "log in" on target "User account in environment 'AzureStackAdmin'".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
DEBUG: 9:23:56 AM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 9:23:56 AM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 9:23:56 AM - Using Autosave scope 'CurrentUser'
The same behavior is observed with Az 8.0.0 version module.
### Issue script & Debug output
```PowerShell
PS C:\Users\Administrator.AZS-DVM> Connect-AzAccount -Environment "AzureStackAdmin" -Debug -Verbose
DEBUG: 9:23:53 AM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: 9:23:55 AM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 9:23:55 AM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 9:23:55 AM - Using Autosave scope 'CurrentUser'
Confirm
Are you sure you want to perform this action?
Performing the operation "log in" on target "User account in environment 'AzureStackAdmin'".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
DEBUG: 9:23:56 AM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 9:23:56 AM - No autosave setting detected in environment variable 'AzContextAutoSave'.
DEBUG: 9:23:56 AM - Using Autosave scope 'CurrentUser'
```
### Environment data
```PowerShell
PS C:> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17763.10520
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.10520
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:>
```
### Module versions
```PowerShell
PS C:\Users\Administrator.AZS-DVM> Get-Module az*
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 2.2.8 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
PS C:\Users\Administrator.AZS-DVM>
```
### Error output
_No response_
Contributor guide
Research direction
Start by reproducing Connect-AzAccount -Environment "AzureStackAdmin" -Debug -Verbose with Az.Accounts 2.8.0 or Az 8.0.0 on the reported Windows PowerShell environment. Trace the authentication flow after login verification, where the debug output stops, and use the reported module and environment details to identify the hang. Done means the command completes or reports a clear failure instead of remaining unresponsive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- authentication, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100