I have a situation with our self-hosted (Windows) Azure DevOps agent.
The vm runs two agents – Yes I know it’s not recommended but I thought I could pull it off as we don’t use very resource-intensive workloads, ref: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=yaml%2Cbrowser#can-i-install-multiple-self-hosted-agents-on-the-same-machine.
Sometimes, I guess it’s when two jobs try to start an AzurePowershell task (but it’s hard to investigate that), I get the Access to the path 'GlobalAzurePowerShellConfigInit' is denied.
error.
I though that maybe using separate Powershell installations per user would solve my problem, but then I found this reference in https://github.com/Azure/azure-powershell/blob/main/src/Accounts/Authentication/AzureSessionInitializer.cs which makes me think the “Global” mutex would still block me?
Any ideas for a workaround, or should I simply forget the multiple agents when using AzurePowershell task?
pipeline log:
Starting: my_powershell_task
==============================================================================
Task : Azure PowerShell
Description : Run a PowerShell script within an Azure environment
Version : 5.242.0
Author : Microsoft Corporation
Help : https://aka.ms/azurepowershelltroubleshooting
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:Program FilesPowerShell7pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'E:Agent_2_work_temp5866d915-908c-494a-9f28-3baef6eda200.ps1'"
Added TLS 1.2 in session.
Import-Module -Name C:Program FilesPowerShellModulesAz.Accounts2.13.1Az.Accounts.psd1 -Global
##[error]Access to the path 'GlobalAzurePowerShellConfigInit' is denied.
##[error]PowerShell exited with code '1'.
Disconnect-AzAccount -Scope CurrentUser -ErrorAction Stop
##[warning]INITIALIZATION: Fail to access profile file and will try to use process ContextAutosaveSetting mode. Detailed error: 'The type initializer for 'Microsoft.Azure.Commands.Common.Authentication.ResourceManager.ProtectedFileProvider' threw an exception.'
##[warning]Run Connect-AzAccount to login.
Finishing: my_powershell_task