I install PowerShell and Az module in container based on ubuntu:16.04
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update -y && \
apt-get install powershell -y && \
pwsh -c "Install-Module -Name Az -Force"
It works fine when I ssh to Docker running on my machine,
..but fails with error "Could not find the module Az.Accounts with given version" when executed in Azure DevOps pipeline:
Any ideas how to fix?
What version of Az.Accounts is being loaded? If it is 2.0.0-preview the DevOps task will fail.
You can check for it using Get-InstalledModule Az.Accounts -AllVersions
If it is the case use:
Uninstall-Module -Name Az.Accounts -RequiredVersion 2.0.0-preview -AllowPrerelease
to remove the preview then add the current version:
Install-Module -Name Az.Accounts -RequiredVersion 1.7.0
I have no idea why the preview gets installed but it has plagued me for a while...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With