Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Connect-AzAccount is hanging #18671

Open asagade opened 2 years ago

asagade commented 2 years ago

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

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

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

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

dingmeng-xue commented 2 years ago

Thanks for contacting us. The version of Az.Accounts in output of Get-Module az* shows 2.2.8. Please double check the version of Az.Accounts you are using.

If you have AzureStack user, you need to use recommended Az version for AzureStack environment. Such as Az 1.10.0.

asagade commented 2 years ago

I use the following link to Install the PowerShell Az module for Azure Stack Hub, in that mention to use Az 2.0.1 https://docs.microsoft.com/en-us/azure-stack/operator/powershell-install-az-module?view=azs-2102

Pasqual24 commented 2 years ago

I'm having the same issue. The Connect-AzAccount command, ran from within a script locally, often hangs indefinitely after I clicked to choose my organization's account in the pop-up window that appear. The login window closes, but the script stays "frozen" without any output. Ctrl + C doesn't stop the script either, the PS console window has to be closed.

After a few tries (closing the PS window and running the script again), the login finally goes through. The issue happens very frequently for me and my colleagues.

PS C:\Users\pascadmin> $PSVersionTable

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

PS C:\Users\pascadmin> Get-InstalledModule Az*

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
2.10.0               Az.Accounts                         PSGallery            Microsoft Azure PowerShell - Accounts credential management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.2                Az.Advisor                          PSGallery            Microsoft Azure PowerShell - Azure Advisor Cmdlets for Advisor in Windows PowerShell and PowerShell Core. Get Advisor recommendations, Manage Advisor configurations.
3.1.0                Az.Aks                              PSGallery            Microsoft Azure PowerShell - Azure managed Kubernetes cmdlets for Windows PowerShell and PowerShell Core....
1.1.4                Az.AnalysisServices                 PSGallery            Microsoft Azure PowerShell - Analysis Services cmdlets for Windows PowerShell and PowerShell Core....
2.3.1                Az.ApiManagement                    PSGallery            Microsoft Azure PowerShell - Api Management service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.3.0                Az.ApplicationInsights              PSGallery            Microsoft Azure PowerShell - Application Insights management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.  Creates and manages application insights in Azure...
1.7.3                Az.Automation                       PSGallery            Microsoft Azure PowerShell - Automation service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
3.1.1                Az.Batch                            PSGallery            Microsoft Azure PowerShell - Batch service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
2.0.0                Az.Billing                          PSGallery            Microsoft Azure PowerShell - Billing service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
0.2.3                Az.Blueprint                        PSGallery            Microsoft Azure PowerShell - Blueprint service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.8.1                Az.Cdn                              PSGallery            Microsoft Azure PowerShell - CDN service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.10.0               Az.CognitiveServices                PSGallery            Microsoft Azure PowerShell - Cognitive Services management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core. Creates and manages cognitive services accounts in A...
4.22.0               Az.Compute                          PSGallery            Microsoft Azure PowerShell - Compute service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.  Manages virtual machines, hosted services, and related resources ...
3.0.0                Az.ContainerInstance                PSGallery            Microsoft Azure PowerShell: ContainerInstance cmdlets
2.2.3                Az.ContainerRegistry                PSGallery            Microsoft Azure PowerShell - Container Registry service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.0                Az.DataBoxEdge                      PSGallery            Microsoft Azure PowerShell - DataBoxEdge service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.16.2               Az.DataFactory                      PSGallery            Microsoft Azure PowerShell - Data Factory service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.0.2                Az.DataLakeAnalytics                PSGallery            Microsoft Azure PowerShell - Data Lake Analytics in Windows PowerShell and PowerShell Core....
1.3.0                Az.DataLakeStore                    PSGallery            Microsoft Azure PowerShell - Azure Data Lake Store cmdlets in Windows PowerShell and PowerShell Core....
1.0.0                Az.DataShare                        PSGallery            Microsoft Azure PowerShell - DataShare service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
1.1.0                Az.DeploymentManager                PSGallery            PowerShell .Net Core Microsoft Azure PowerShell - Deployment Manager cmdlets for Azure Resource Manager....
3.1.0                Az.DesktopVirtualization            PSGallery            Microsoft Azure PowerShell: DesktopVirtualization cmdlets
1.0.2                Az.DevTestLabs                      PSGallery            Microsoft Azure PowerShell - DevTest Labs service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.2                Az.Dns                              PSGallery            Microsoft Azure PowerShell - DNS service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.3.0                Az.EventGrid                        PSGallery            Microsoft Azure PowerShell - Event Grid service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.9.1                Az.EventHub                         PSGallery            Microsoft Azure PowerShell - Event Hubs service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.9.0                Az.FrontDoor                        PSGallery            Microsoft Azure PowerShell - Front Door service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
4.0.1                Az.Functions                        PSGallery            Microsoft Azure PowerShell - Azure Functions service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
5.0.0                Az.HDInsight                        PSGallery            Microsoft Azure PowerShell - HDInsight service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.3.1                Az.HealthcareApis                   PSGallery            Microsoft Azure PowerShell - HealthcareApis management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core. Creates and manages HealthcareApis service accounts in A...
2.7.4                Az.IotHub                           PSGallery            Microsoft Azure PowerShell - IoT Hub service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
4.7.0                Az.KeyVault                         PSGallery            Microsoft Azure PowerShell - Key Vault service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.5.0                Az.LogicApp                         PSGallery            Microsoft Azure PowerShell - Logic Apps cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.3                Az.MachineLearning                  PSGallery            Microsoft Azure PowerShell - Machine Learning Web Services cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.2.0                Az.Maintenance                      PSGallery            Microsoft Azure PowerShell - Maintenance cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
3.0.0                Az.ManagedServices                  PSGallery            Microsoft Azure PowerShell: ManagedServices cmdlets
1.0.2                Az.MarketplaceOrdering              PSGallery            Microsoft Azure PowerShell - Marketplace Ordering agreements service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.1                Az.Media                            PSGallery            Microsoft Azure PowerShell - Media service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
3.0.0                Az.Monitor                          PSGallery            Microsoft Azure PowerShell - Monitor service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
4.14.0               Az.Network                          PSGallery            Microsoft Azure PowerShell - Networking service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.1                Az.NotificationHubs                 PSGallery            Microsoft Azure PowerShell - Notification Hubs cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
3.0.0                Az.OperationalInsights              PSGallery            Microsoft Azure PowerShell - Operational Insights service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
1.4.1                Az.PolicyInsights                   PSGallery            Microsoft Azure PowerShell - Azure Policy Insights cmdlets for Windows PowerShell and PowerShell Core. Allows querying policy evaluation events and compliance states....
1.1.2                Az.PowerBIEmbedded                  PSGallery            Microsoft Azure PowerShell - Power BI Embedded service management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.  Creates and manages Power BI Embedded worksp...
1.0.3                Az.PrivateDns                       PSGallery            Microsoft Azure PowerShell - Private DNS service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
5.0.0                Az.RecoveryServices                 PSGallery            Microsoft Azure PowerShell - Recovery Services cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.6.0                Az.RedisCache                       PSGallery            Microsoft Azure PowerShell - Redis Cache service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.0.3                Az.Relay                            PSGallery            Microsoft Azure PowerShell - Relay service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
5.2.0                Az.Resources                        PSGallery            Microsoft Azure PowerShell - Azure Resource Manager and Active Directory cmdlets in Windows PowerShell and PowerShell Core.  Manages subscriptions, tenants, resource groups, deployment temp...
1.1.1                Az.Security                         PSGallery            Microsoft Azure PowerShell - Azure Security Center cmdlets in Windows PowerShell and PowerShell Core. Allows managing and monitoring the security posture of your resources....
1.6.0                Az.ServiceBus                       PSGallery            Microsoft Azure PowerShell - Service Bus service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
3.0.1                Az.ServiceFabric                    PSGallery            Microsoft Azure PowerShell - Service Fabric cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.4.1                Az.SignalR                          PSGallery            Microsoft Azure PowerShell - Azure SignalR service commands for Windows PowerShell and PowerShell Core....
3.7.0                Az.Sql                              PSGallery            Microsoft Azure PowerShell - SQL service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.0                Az.SqlVirtualMachine                PSGallery            Microsoft Azure PowerShell - SqlVirtualMachine service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
4.1.1                Az.Storage                          PSGallery            Microsoft Azure PowerShell - Storage service data plane and management cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.  Creates and manages storage accounts in...
1.6.1                Az.StorageSync                      PSGallery            Microsoft Azure PowerShell - Storage Sync cmdlets in Windows PowerShell and PowerShell Core. Manages operations pertaining to Azure File Sync in PowerShell.
2.0.0                Az.StreamAnalytics                  PSGallery            Microsoft Azure PowerShell: StreamAnalytics cmdlets
0.8.0                Az.Subscription                     PSGallery            Microsoft Azure PowerShell - Subscription cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
1.0.0                Az.Support                          PSGallery            Microsoft Azure PowerShell - Azure Support cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core.
1.0.4                Az.TrafficManager                   PSGallery            Microsoft Azure PowerShell - Traffic Manager service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
2.9.0                Az.Websites                         PSGallery            Microsoft Azure PowerShell - App Service (Web Apps) service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
2.0.2.135            AzureAD                             PSGallery            Azure Active Directory V2 General Availability Module....
4.8.0                Az                                  PSGallery            Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module is compatible with WindowsPowerShell and PowerShell Core....
1.0.0                Az.AppConfiguration                 PSGallery            Microsoft Azure PowerShell: AppConfiguration cmdlets
1.0.0                Az.Attestation                      PSGallery            Microsoft Azure PowerShell - Attestation service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.0.0                Az.CloudService                     PSGallery            Microsoft Azure PowerShell: CloudService cmdlets
1.5.1                Az.CosmosDB                         PSGallery            Microsoft Azure PowerShell - CosmosDB service cmdlets for Azure Resource Manager in Windows PowerShell and PowerShell Core....
1.1.0                Az.Databricks                       PSGallery            Microsoft Azure PowerShell: Databricks cmdlets
2.0.0                Az.Kusto                            PSGallery            Microsoft Azure PowerShell: Kusto cmdlets
1.1.2                Az.Migrate                          PSGallery            Microsoft Azure PowerShell: Migrate cmdlets
1.0.0                Az.MySql                            PSGallery            Microsoft Azure PowerShell: MySql cmdlets
1.0.0                Az.PostgreSql                       PSGallery            Microsoft Azure PowerShell: PostgreSql cmdlets
1.0.0                Az.RedisEnterpriseCache             PSGallery            Microsoft Azure PowerShell: RedisEnterpriseCache cmdlets
1.1.0                Az.ResourceMover                    PSGallery            Microsoft Azure PowerShell: ResourceMover cmdlets
1.1.0                Az.SecurityInsights                 PSGallery            Microsoft Azure PowerShell - Azure Sentinel cmdlets in Windows PowerShell and PowerShell Core. Allows managing and monitoring the security posture of your resources....
1.0.0                Az.StackHCI                         PSGallery            Microsoft Azure PowerShell: Azure Stack HCI registration cmdlets
1.0.0                Az.Synapse                          PSGallery            Microsoft Azure PowerShell - Azure Synapse Analytics in Windows PowerShell and PowerShell Core....
5.1.2                Azure                               PSGallery            Microsoft Azure PowerShell - Service Management
4.6.1                Azure.Storage                       PSGallery            Microsoft Azure PowerShell - Storage service cmdlets. Manages blobs, queues, tables and files in Microsoft Azure storage accounts
5.8.4                AzureRM.profile                     PSGallery            Microsoft Azure PowerShell - Profile credential management cmdlets for Azure Resource Manager
dingmeng-xue commented 2 years ago

@Pasqual24 , thanks for reporting. Your case should be different from original one because your Az.Accounts is almost the latest one. Login Windows pop up and authentication flow is fully controlled by MSAL. Could you create an new Github issue and post log during Connect-AzAccounts? You can get log after you set $DebugPreference = "Continue"