Azure / Azure/azure-powershell
update-azconfig : The process cannot access the file 'C:\...\.Azure\PSConfig.json' because it is being used by another process.
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
### 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
```PowerShell
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
```PowerShell
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
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 3.0.3 az.accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
```
### Error output
_No response_
Contributor guide
Research direction
Start by running the reported ten-process reproduction with Update-AzConfig and Az.Accounts 3.0.3, then trace how the cmdlet accesses PSConfig.json. Done means the parallel invocations complete without the file-in-use IOException while preserving the configuration update.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100