Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

update-azconfig : The process cannot access the file 'C:\...\.Azure\PSConfig.json' because it is being used by another process. #25778

Open DanielMannInCycle opened 1 month ago

DanielMannInCycle commented 1 month ago

Description

This was first noticed in an Azure DevOps pipeline using the AzurePowerShell@5 task with Az 8.0.0 and the Az.Accounts module 2.9.1,, but I was able to create a minimal repro case that occurs even on my local machine.

This error occurs with every version of Az.Accounts I've tested with between version 2.8.0 and 3.0.3. It doesn't occur with Az.Accounts 2.7.6 because the Update-AzConfig cmdlet does not exist in that version.

Issue script & Debug output

1..10 | foreach-object -parallel { 
start powershell { import-module az.accounts -requiredversion 3.0.3; update-azconfig -displaybreakingchangewarning $false -appliesto az; read-host }
}

Some of the windows display no error, the rest display

update-azconfig : The process cannot access the file 'C:\Users\danie.Azure\PSConfig.json' because it is being used by another process. At line:1 char:51

  • ... sion 3.0.3; update-azconfig -displaybreakingchangewarning $false -app ...
  • CategoryInfo : CloseError: (:) [Update-AzConfig], IOException
  • FullyQualifiedErrorId : Microsoft.Azure.Commands.Common.Authentication.Config.UpdateConfigCommand

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.4
PSEdition                      Core
GitCommitId                    7.4.4
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.3                 az.accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…

Error output

No response

DanielMannInCycle commented 1 month ago

Related: https://github.com/microsoft/azure-pipelines-tasks/issues/20226