PowershellFrameworkCollective / psframework

A module that provides tools for other modules and scripts
MIT License
435 stars 42 forks source link

[AzureDevOps][Ubuntu-Latest] Intermittent import error #528

Open FriedrichWeinmann opened 2 years ago

FriedrichWeinmann commented 2 years ago

See: https://github.com/Azure/AzOps/discussions/656 When multithreading using ForEach-Object -Parallel, some runspaces appear to not import PSFramework correctly, missing the command.

FriedrichWeinmann commented 2 years ago

Was unable to repro in the first sets of tests, will keep trying.

jsandquist commented 1 year ago

As related to AzOps mentioned here we might just close this.

Not specific to PSF as far as I can tell - and I just experienced something similar on Windows (!) with PowerShell 7.3.2 running in the context of an Azure Pipelines agent:

Pipeline run attempt 1:

"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'Q:\App\agent-2\_work\_temp\29e5c900-5b73-4d57-992a-4133d47abfe0.ps1'"
WARNING: [12:42:47][Initialize-AzOpsEnvironment] No context available in Az PowerShell. Please use Connect-AzAccount and connect before using the command
Invoke-AzOpsPush : The 'Invoke-AzOpsPush' command was found in the module 'AzOps', but the module could not be loaded. For more information, run 'Import-Module AzOps'.

Pipeline re-run (thus attempt 2) - on the very same agent - a few minutes later the re-run succeeded just fine:

"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'Q:\App\agent-2\_work\_temp\a9001116-68d8-4e6c-90d0-bc47aec211d9.ps1'"
[13:03:32][Initialize-AzOpsEnvironment] Processing AzOps environment
...