Forum Discussion
PowerShell Az module missing from latest Microsoft-hosted Agents???
Goals
- Use PowerShell Az module when executing an Azure DevOps Pipeline
- Avoid installing Az from scratch (takes several minutes)
I want to execute Az module commands from a Pipeline running on a Microsoft-hosted build agent. According to https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md ubuntu-latest and windows-latest images have Az pre-installed.
Running Get-Module -ListAvailable -Name Az on Microsoft-hosted build agents returns nothing, blank, null... The Pipeline is telling me that PowerShell Az module is not available.
Running Import-Module -Name Az throws "The specified module 'Az' was not loaded because no valid module file was found in any module directory".
Test Pipeline Code
1 Reply
May try to below as workaround:
steps: - pwsh: | Install-Module -Name Az -Scope CurrentUser -Force -AllowClobber Import-Module Az displayName: 'Install and Import Az Module'
Suggestions:
• Use a self-hosted agent with Az pre-installed.
• Or cache the module between pipeline runs using Azure Pipeline Caching.