Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import-Module Az.Accounts fails with "Access to the path 'Global\AzurePowerShellConfigInit' is denied" when used concurrent #26907

Open
zeilemaker54 opened this issue Dec 19, 2024 · 5 comments
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue.

Comments

@zeilemaker54
Copy link

zeilemaker54 commented Dec 19, 2024

Description

This is how to ‘build’ an environment to reproduce the issue on a windows computer:

  1. Create 4 local accounts with no additional permissions

  2. Create a folder for powershell scripts

  3. Create a powershell script called test-azaccounts.ps1 with the following content:
    . "$PSScriptRoot\test-azaccounts2.ps1" *>> "$home\Documents\test-azaccounts.log"

  4. Create a powershell script called test-azaccounts2.ps1 with the following content:

$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
$DebugPreference = 'Continue'

Write-Information "$(Get-Date) Start"

try {
  $null = Import-Module Az.Accounts
}
catch {
  Write-Information "$(Get-Date) Error: $($_.Exception.Message)"
}
Write-Information "$(Get-Date) End"

  1. Create a scheduled task for each local account (running as the local account) with the same trigger/schedule running script test-azaccount.ps1 (run powershell.exe with arguments: -noninteractive -file \test-azaccounts.ps1)
    The script will create a logfile in the document folder of each local account.
    You will notice that only 1 scheduled task will succeed, the other 3 will fail.

Issue script & Debug output

See description

Environment data

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

Module versions

On 1 of the instances:
Script     3.0.3                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…

On the other instances:

Error output

On 1 of the instances the following is logged:

12/19/2024 13:30:02 Start
Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.4.6].
Initializing ConditionalAssemblyProvider. AssemblyRootPath is [C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\3.0.3\StartupScripts\..\lib].
Registering Az shared AssemblyLoadContext.
AssemblyLoadContext registered.
12/19/2024 13:30:04 End

On the other instances:
12/19/2024 13:30:02 Start
Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.4.6].
Initializing ConditionalAssemblyProvider. AssemblyRootPath is [C:\Program Files\WindowsPowerShell\Modules\Az.Accounts\3.0.3\StartupScripts\..\lib].
Registering Az shared AssemblyLoadContext.
AssemblyLoadContext registered.
12/19/2024 13:30:04 Error: Access to the path 'Global\AzurePowerShellConfigInit' is denied.
12/19/2024 13:30:04 End
@zeilemaker54 zeilemaker54 added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Dec 19, 2024
@lzandman
Copy link

This looks very similar to this issue I reported: microsoft/azure-pipelines-tasks#20245

@isra-fel
Copy link
Member

isra-fel commented Jan 9, 2025

It seems caused by mutex created by one user can't be accessed by other users. Can the script be modified to run with one single user?

@isra-fel isra-fel added needs-author-feedback More information is needed from author to address the issue. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jan 9, 2025
@lzandman
Copy link

lzandman commented Jan 9, 2025

It seems caused by mutex created by one user can't be accessed by other users. Can the script be modified to run with one single user?

It also happens when all processes are run by the same user.

@isra-fel
Copy link
Member

Then I assume it's a different problem with a different root cause.
See #25778

@microsoft-github-policy-service microsoft-github-policy-service bot added the no-recent-activity There has been no recent activity on this issue. label Jan 17, 2025
Copy link
Contributor

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported needs-author-feedback More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

No branches or pull requests

3 participants