Skip to content

PowerShell hangs with high CPU load when running Connect-AzAccount #15587

Closed
@maximilianpalm

Description

@maximilianpalm

Description

I just installed PowerShell and Azure PowerShell for the first time on my Ubuntu 20.04.2 LTS machine. However, when running Connect-AzAccount, the process hangs and I cannot continue.

Steps to reproduce

Installation of PowerShell in bash

sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo add-apt-repository universe
sudo apt-get install -y powershell
sudo pwsh

Installation of Az module

PS /home/user> Install-Module Az -AllowClobber
PS /home/user> Import-Module Az

This opens a window with a password query to unlock the default-keyring.

Reproduce issue

PS /home/user> $DebugPreference='Continue'
PS /home/user> Connect-AzAccount
DEBUG: Sought all Az modules and got latest version 6.2.1
DEBUG: 12:01:11 PM - ConnectAzureRmAccountCommand begin processing with ParameterSet 'UserWithSubscriptionId'.
DEBUG: 12:01:11 PM - Autosave setting from startup session: 'CurrentUser'
DEBUG: 12:01:11 PM - No autosave setting detected in environment variable 'AzContextAutoSave'. 
DEBUG: 12:01:11 PM - Using Autosave scope 'CurrentUser'

After this, nothing else happens, except for the pwsh process consuming 100% of a CPU thread continuously for minutes. I can still abort the process with Ctrl+C. I tried restarting the pwsh and bash shells, with no effect.

user@box:~$ ps aux | grep pwsh
root      179093  0.0  0.0  12372  4996 pts/0    S+   11:35   0:00 sudo pwsh
root      179094 65.7  0.8 4180848 142824 pts/0  SLl+ 11:35   3:43 pwsh
user      179607  0.0  0.0   9372   736 pts/3    S+   11:41   0:00 grep --color=auto pwsh

Environment data

PS /home/user> $PSVersionTable     

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.4.0-80-generic #90-Ubuntu SMP Fri Jul 9 22:49:44 U…
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS /home/user> Get-Module  -ListAvailable

    Directory: /root/.local/share/powershell/Modules

ModuleType Version    PreRelease Name
---------- -------    ---------- ----                               
Script     6.2.1                 Az                                 
Script     2.5.1                 Az.Accounts                        
Script     1.1.1                 Az.Advisor                         
Script     2.2.0                 Az.Aks                             
Script     1.1.4                 Az.AnalysisServices                
Script     2.2.0                 Az.ApiManagement                   
Script     1.0.0                 Az.AppConfiguration                
Script     1.2.0                 Az.ApplicationInsights             
Script     1.7.0                 Az.Automation                      
Script     3.1.0                 Az.Batch                           
Script     2.0.0                 Az.Billing                         
Script     1.7.1                 Az.Cdn                             
Script     1.8.0                 Az.CognitiveServices               
Script     4.15.0                Az.Compute                         
Script     2.1.0                 Az.ContainerInstance               
Script     2.2.3                 Az.ContainerRegistry               
Script     1.3.0                 Az.CosmosDB                        
Script     1.1.0                 Az.DataBoxEdge                     
Script     1.1.0                 Az.Databricks                      
Script     1.13.0                Az.DataFactory                     
Script     1.0.2                 Az.DataLakeAnalytics               
Script     1.3.0                 Az.DataLakeStore                   
Script     1.0.0                 Az.DataShare                       
Script     1.1.0                 Az.DeploymentManager               
Script     3.0.0                 Az.DesktopVirtualization           
Script     1.0.2                 Az.DevTestLabs                     
Script     1.1.2                 Az.Dns                             
Script     1.3.0                 Az.EventGrid                       
Script     1.8.0                 Az.EventHub                        
Script     1.8.0                 Az.FrontDoor                       
Script     3.1.0                 Az.Functions                       
Script     4.3.0                 Az.HDInsight                       
Script     1.3.1                 Az.HealthcareApis                  
Script     2.7.3                 Az.IotHub                          
Script     3.4.5                 Az.KeyVault                        
Script     2.0.0                 Az.Kusto                           
Script     1.5.0                 Az.LogicApp                        
Script     1.1.3                 Az.MachineLearning                 
Script     1.1.1                 Az.Maintenance                     
Script     2.0.0                 Az.ManagedServices                 
Script     1.0.2                 Az.MarketplaceOrdering             
Script     1.1.1                 Az.Media                           
Script     1.0.2                 Az.Migrate                         
Script     2.6.0                 Az.Monitor                         
Script     4.10.0                Az.Network                         
Script     1.1.1                 Az.NotificationHubs                
Script     2.3.0                 Az.OperationalInsights             
Script     1.4.1                 Az.PolicyInsights                  
Script     1.1.2                 Az.PowerBIEmbedded                 
Script     1.0.3                 Az.PrivateDns                      
Script     4.3.0                 Az.RecoveryServices                
Script     1.4.0                 Az.RedisCache                      
Script     1.0.0                 Az.RedisEnterpriseCache            
Script     1.0.3                 Az.Relay                           
Script     1.0.0                 Az.ResourceMover                   
Script     4.2.0                 Az.Resources                       
Script     1.0.0                 Az.Security                        
Script     1.0.0                 Az.SecurityInsights                
Script     1.5.0                 Az.ServiceBus                      
Script     3.0.0                 Az.ServiceFabric                   
Script     1.3.0                 Az.SignalR                         
Script     3.4.0                 Az.Sql                             
Script     1.1.0                 Az.SqlVirtualMachine               
Script     3.9.0                 Az.Storage                         
Script     1.5.0                 Az.StorageSync                     
Script     2.0.0                 Az.StreamAnalytics                 
Script     1.0.0                 Az.Support                         
Script     1.0.4                 Az.TrafficManager                  
Script     2.8.0                 Az.Websites                        

    Directory: /opt/microsoft/powershell/7/Modules

ModuleType Version    PreRelease Name
---------- -------    ---------- ----                               
Manifest   1.2.5                 Microsoft.PowerShell.Archive       
Manifest   7.0.0.0               Microsoft.PowerShell.Host          
Manifest   7.0.0.0               Microsoft.PowerShell.Management    
Manifest   7.0.0.0               Microsoft.PowerShell.Security      
Manifest   7.0.0.0               Microsoft.PowerShell.Utility       
Script     1.4.7                 PackageManagement                  
Script     2.2.5                 PowerShellGet                      
Script     2.0.5                 PSDesiredStateConfiguration        
Script     2.1.0                 PSReadLine                         
Binary     2.0.3                 ThreadJob                          

Error output

PS /home/user> Resolve-AzError            
WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

   HistoryId: 1

Message        : Cannot find a variable with the name 'ReservedFunctionAppSettingNames'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RequiredStorageEndpoints'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'AllowedStorageTypes'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RuntimeToDefaultOSType'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'SupportedFunctionsVersion'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'FunctionsNoV2Version'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'DefaultFunctionsVersion'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RuntimeToFormattedName'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'ReservedFunctionAppSettingNames'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RequiredStorageEndpoints'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'AllowedStorageTypes'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RuntimeToDefaultOSType'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'SupportedFunctionsVersion'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'FunctionsNoV2Version'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'DefaultFunctionsVersion'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1

Message        : Cannot find a variable with the name 'RuntimeToFormattedName'.
StackTrace     : 
Exception      : System.Management.Automation.ItemNotFoundException
InvocationInfo : {Get-Variable}
Line           :     if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue))
                 
Position       : At /root/.local/share/powershell/Modules/Az.Functions/3.1.0/custom/HelperFunctions.ps1:47 char:15
                 + …   if (-not (Get-Variable $variableName -ErrorAction SilentlyContinue) …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 1


The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.

Metadata

Metadata

Assignees

Labels

customer-reportedquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions