Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.24k stars 3.84k forks source link

Az module cannot be imported in parallel #18321

Closed tbish967 closed 2 years ago

tbish967 commented 2 years ago

Description

The Az module cannot be imported by jobs running in parallel because of contention for access to the ~/.azure/psconfig.json file, as seen in the first error line in the debug output. This seems like a recent issue, since our organization first saw it on 5/24, but I've seen it on both the current PS5 version and a version released before 5/24, so there might be some external factor.

This may also happen with multiple session - it behaves like an issue with the filesystem, rather than the individual Powershell session. I've tried this with delays between jobs, and this resolves the issue, but isn't a reliable fix since module imports vary in timing, so concurrent jobs importing any module dependent on Az will intermittently fail.

Issue script & Debug output

PS C:\Users\localadmin> $DebugPreference='Continue'
PS C:\Users\localadmin> $jobs = @()
PS C:\Users\localadmin> import-module az
PS C:\Users\localadmin> $jobs += Start-Job -name "test-1" -ScriptBlock { Import-Module Az }
PS C:\Users\localadmin> $jobs += Start-Job -name "test-1" -ScriptBlock { Import-Module Az }
PS C:\Users\localadmin> $jobs += Start-Job -name "test-1" -ScriptBlock { Import-Module Az }
PS C:\Users\localadmin> $jobs += Start-Job -name "test-1" -ScriptBlock { Import-Module Az }
PS C:\Users\localadmin> $jobs += Start-Job -name "test-1" -ScriptBlock { Import-Module Az }
PS C:\Users\localadmin> $jobs | Wait-Job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
43     test-1          BackgroundJob   Completed     True            localhost             Import-Module Az
45     test-1          BackgroundJob   Completed     True            localhost             Import-Module Az
47     test-1          BackgroundJob   Completed     True            localhost             Import-Module Az
49     test-1          BackgroundJob   Completed     True            localhost             Import-Module Az
51     test-1          BackgroundJob   Completed     True            localhost             Import-Module Az

PS C:\Users\localadmin> $jobs | Receive-Job
The process cannot access the file 'C:\Users\localadmin\.Azure\PSConfig.json' because it is being used by another
process.
    + CategoryInfo          : NotSpecified: (:) [Import-Module], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.ImportModuleCommand
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The process cannot access the file 'C:\Users\localadmin\.Azure\PSConfig.json' because it is being used by another
process.
    + CategoryInfo          : NotSpecified: (:) [Import-Module], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.ImportModuleCommand
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Register-AzModule:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    + PSComputerName        : localhost

PS C:\Users\localadmin> $jobs | Remove-Job

Environment data

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

Module versions

PS C:\Users\localadmin> Get-Module Az*

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     8.0.0      az
Script     2.8.0      Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear...
Script     1.1.2      Az.Advisor                          {Disable-AzAdvisorRecommendation, Enable-AzAdvisorRecommen...
Script     4.1.0      Az.Aks                              {Disable-AzAksAddOn, Enable-AzAksAddOn, Get-AzAksCluster, ...
Script     1.1.4      Az.AnalysisServices                 {Add-AzAnalysisServicesAccount, Export-AzAnalysisServicesI...
Script     3.0.0      Az.ApiManagement                    {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiTo...
Script     1.1.0      Az.AppConfiguration                 {Get-AzAppConfigurationStore, Get-AzAppConfigurationStoreK...
Script     2.0.0      Az.ApplicationInsights              {Get-AzApplicationInsights, Get-AzApplicationInsightsApiKe...
Script     1.0.0      Az.Attestation                      {Add-AzAttestationPolicySigner, Get-AzAttestation, Get-AzA...
Script     1.7.3      Az.Automation                       {Export-AzAutomationDscConfiguration, Export-AzAutomationD...
Script     3.2.0      Az.Batch                            {Disable-AzBatchAutoScale, Disable-AzBatchComputeNodeSched...
Script     2.0.0      Az.Billing                          {Get-AzBillingAccount, Get-AzBillingInvoice, Get-AzBilling...
Script     2.1.0      Az.Cdn                              {Clear-AzCdnEndpointContent, Clear-AzFrontDoorCdnEndpointC...
Script     1.1.0      Az.CloudService                     {Get-AzCloudService, Get-AzCloudServiceInstanceView, Get-A...
Script     1.11.0     Az.CognitiveServices                {Add-AzCognitiveServicesAccountNetworkRule, Get-AzCognitiv...
Script     4.27.0     Az.Compute                          {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnatten...
Script     3.1.0      Az.ContainerInstance                {Add-AzContainerInstanceOutput, Get-AzContainerGroup, Get-...
Script     3.0.0      Az.ContainerRegistry                {Connect-AzContainerRegistry, Get-AzContainerRegistry, Get...
Script     1.8.0      Az.CosmosDB                         {Get-AzCosmosDBAccount, Get-AzCosmosDBAccountKey, Get-AzCo...
Script     1.1.0      Az.DataBoxEdge                      {Get-AzDataBoxEdgeBandwidthSchedule, Get-AzDataBoxEdgeDevi...
Script     1.2.0      Az.Databricks                       {Get-AzDatabricksOutboundNetworkDependenciesEndpoint, Get-...
Script     1.16.7     Az.DataFactory                      {Add-AzDataFactoryV2DataFlowDebugSessionPackage, Add-AzDat...
Script     1.0.2      Az.DataLakeAnalytics                {Add-AzDataLakeAnalyticsDataSource, Add-AzDataLakeAnalytic...
Script     1.3.0      Az.DataLakeStore                    {Add-AzDataLakeStoreFirewallRule, Add-AzDataLakeStoreItemC...
Script     1.0.1      Az.DataShare                        {Get-AzDataShare, Get-AzDataShareAccount, Get-AzDataShareD...
Script     1.1.0      Az.DeploymentManager                {Get-AzDeploymentManagerArtifactSource, Get-AzDeploymentMa...
Script     3.1.0      Az.DesktopVirtualization            {Disconnect-AzWvdUserSession, Expand-AzWvdMsixImage, Get-A...
Script     1.0.2      Az.DevTestLabs                      {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolic...
Script     1.1.2      Az.Dns                              {Add-AzDnsRecordConfig, Get-AzDnsRecordSet, Get-AzDnsZone,...
Script     1.3.0      Az.EventGrid                        {Get-AzEventGridDomain, Get-AzEventGridDomainKey, Get-AzEv...
Script     2.0.0      Az.EventHub                         {Add-AzEventHubIPRule, Add-AzEventHubVirtualNetworkRule, G...
Script     1.9.0      Az.FrontDoor                        {Disable-AzFrontDoorCustomDomainHttps, Enable-AzFrontDoorC...
Script     4.0.3      Az.Functions                        {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Ge...
Script     5.0.1      Az.HDInsight                        {Add-AzHDInsightClusterIdentity, Add-AzHDInsightComponentV...
Script     2.0.0      Az.HealthcareApis                   {Get-AzHealthcareApisService, Get-AzHealthcareApisWorkspac...
Script     2.7.4      Az.IotHub                           {Add-AzIotHubCertificate, Add-AzIotHubConfiguration, Add-A...
Script     4.5.0      Az.KeyVault                         {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateConta...
Script     2.1.0      Az.Kusto                            {Add-AzKustoClusterLanguageExtension, Add-AzKustoDatabaseP...
Script     1.5.0      Az.LogicApp                         {Get-AzIntegrationAccount, Get-AzIntegrationAccountAgreeme...
Script     1.1.3      Az.MachineLearning                  {Add-AzMlWebServiceRegionalProperty, Export-AzMlWebService...
Script     1.2.0      Az.Maintenance                      {Get-AzApplyUpdate, Get-AzConfigurationAssignment, Get-AzM...
Script     1.0.0      Az.ManagedServiceIdentity           {Get-AzSystemAssignedIdentity, Get-AzUserAssignedIdentity,...
Script     3.0.0      Az.ManagedServices                  {Get-AzManagedServicesAssignment, Get-AzManagedServicesDef...
Script     1.0.2      Az.MarketplaceOrdering              {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script     1.1.1      Az.Media                            {Get-AzMediaService, Get-AzMediaServiceKey, Get-AzMediaSer...
Script     1.1.2      Az.Migrate                          {Get-AzMigrateDiscoveredServer, Get-AzMigrateJob, Get-AzMi...
Script     3.0.1      Az.Monitor                          {Add-AzAutoscaleSetting, Add-AzLogProfile, Add-AzMetricAle...
Script     1.0.0      Az.MySql                            {Get-AzMySqlConfiguration, Get-AzMySqlConnectionString, Ge...
Script     4.17.0     Az.Network                          {Add-AzApplicationGatewayAuthenticationCertificate, Add-Az...
Script     1.1.1      Az.NotificationHubs                 {Get-AzNotificationHub, Get-AzNotificationHubAuthorization...
Script     3.1.0      Az.OperationalInsights              {Disable-AzOperationalInsightsIISLogCollection, Disable-Az...
Script     1.5.0      Az.PolicyInsights                   {Get-AzPolicyEvent, Get-AzPolicyMetadata, Get-AzPolicyReme...
Script     1.1.0      Az.PostgreSql                       {Get-AzPostgreSqlConfiguration, Get-AzPostgreSqlConnection...
Script     1.1.2      Az.PowerBIEmbedded                  {Get-AzPowerBIEmbeddedCapacity, Get-AzPowerBIWorkspace, Ge...
Script     1.0.3      Az.PrivateDns                       {Add-AzPrivateDnsRecordConfig, Get-AzPrivateDnsRecordSet, ...
Script     5.4.0      Az.RecoveryServices                 {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Ba...
Script     1.6.0      Az.RedisCache                       {Export-AzRedisCache, Get-AzRedisCache, Get-AzRedisCacheFi...
Script     1.0.0      Az.RedisEnterpriseCache             {Export-AzRedisEnterpriseCache, Get-AzRedisEnterpriseCache...
Script     1.0.3      Az.Relay                            {Get-AzRelayAuthorizationRule, Get-AzRelayHybridConnection...
Script     1.1.0      Az.ResourceMover                    {Add-AzResourceMoverMoveResource, Get-AzResourceMoverMoveC...
Script     6.0.0      Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDeny...
Script     1.3.0      Az.Security                         {Add-AzSecurityAdaptiveNetworkHardening, Add-AzSecuritySql...
Script     1.1.0      Az.SecurityInsights                 {Get-AzSentinelAlertRule, Get-AzSentinelAlertRuleAction, G...
Script     1.9.0      Az.ServiceBus                       {Add-AzServiceBusIPRule, Add-AzServiceBusVirtualNetworkRul...
Script     3.0.2      Az.ServiceFabric                    {Add-AzServiceFabricClientCertificate, Add-AzServiceFabric...
Script     1.4.1      Az.SignalR                          {Get-AzSignalR, Get-AzSignalRKey, Get-AzSignalRUsage, New-...
Script     3.9.0      Az.Sql                              {Add-AzSqlDatabaseToFailoverGroup, Add-AzSqlElasticJobStep...
Script     1.1.0      Az.SqlVirtualMachine                {Get-AzAvailabilityGroupListener, Get-AzSqlVM, Get-AzSqlVM...
Script     1.1.1      Az.StackHCI                         {Add-AzStackHCIVMAttestation, Disable-AzStackHCIAttestatio...
Script     4.6.0      Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountMa...
Script     1.7.0      Az.StorageSync                      {Get-AzStorageSyncCloudEndpoint, Get-AzStorageSyncGroup, G...
Script     2.0.0      Az.StreamAnalytics                  {Get-AzStreamAnalyticsCluster, Get-AzStreamAnalyticsCluste...
Script     1.0.0      Az.Support                          {Get-AzSupportProblemClassification, Get-AzSupportService,...
Script     1.4.0      Az.Synapse                          {Add-AzSynapseDataFlowDebugSessionPackage, Add-AzSynapseTr...
Script     1.1.0      Az.TrafficManager                   {Add-AzTrafficManagerCustomHeaderToEndpoint, Add-AzTraffic...
Script     2.11.2     Az.Websites                         {Add-AzWebAppAccessRestrictionRule, Add-AzWebAppTrafficRou...

Error output

PS C:\Users\localadmin> Resolve-AzError
DEBUG: Sought all Az modules and got latest version 0.0.0
DEBUG: 8:08:16 PM - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 8:08:16 PM - using account id 'MSI@50342'...
DEBUG: 8:08:16 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = [].
Returning default value [True].
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:

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The term 'Register-AzModule' is not recognized as the name of a cmdlet, function, script file, or
                 operable program. Check the spelling of the name, or if a path was included, verify that the path is
                 correct and try again.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

Message        : The process cannot access the file 'C:\Users\localadmin\.Azure\PSConfig.json' because it is being
                 used by another process.
StackTrace     :
Exception      : System.Management.Automation.RemoteException
InvocationInfo : {}
Line           :
Position       :
HistoryId      :

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

DEBUG: 8:08:17 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning
default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:2.8.0; CommandName: Resolve-AzError; PSVersion: 5.1.17763.2867; IsSuccess:
True; Duration: 00:00:00.4108643
DEBUG: Finish sending metric.
DEBUG: 8:08:17 PM - ResolveError end processing.
tbish967 commented 2 years ago

Hi everyone,

Just a quick update - I've confirmed that this is an issue with Az.Accounts 2.8.0, and specifically the AzureSessionInitializer code here:

https://github.com/Azure/azure-powershell/blob/5ea071fbae27e8d95de3ed74ad8c4af9315f012d/src/Accounts/Authentication/AzureSessionInitializer.cs#L249-L259

It looks like module imports lock PSConfig.json and cause concurrent ones to fail.

dingmeng-xue commented 2 years ago

Thanks for reporting. @isra-fel , let's fix it in upcoming release.

kiazhi commented 2 years ago

Yes, confirmed that switching the Az.Accounts module to an older version resolved our issue.

Install-Module -Name Az ;
Uninstall-Module -Name Az.Accounts -AllVersions ;
Install-Module -Name Az.Accounts -RequiredVersion 2.7.6 -Force -Verbose ;
brwilkinson commented 2 years ago

I seem to also have this new error relating to psconfig.json

Import-Module: The process cannot access the file 'C:\Users\<user>\.Azure\PSConfig.json' because it is being used by another process.

.: The script 'Get-PimRole.ps1' cannot be run because the following modules that are specified by the "#requires" statements of the script are missing: Az.Resources.

commenting to follow.

isra-fel commented 2 years ago

@brwilkinson Hi Ben, if the issue persists, or if you have more info, could you submit a new issue so that I can follow up? Thanks.

brwilkinson commented 2 years ago

Thanks @isra-fel I saw this a few times. Will keep an eye and provide more info if persists. I wanted to drop a note if others have the similar issue.

lucidqdreams commented 1 year ago

I am getting this error in WAC image

chandlerkent commented 1 year ago

We are still having this issue

ChrisGibson1982 commented 2 months ago

Is there any update on this?