在 Docker 中运行 Azure DevOps 作业时出现“无法找到给定版本的模块 Az.Accounts”错误

2024-01-19

我在基于 ubuntu:16.04 的容器中安装 PowerShell 和 Az 模块

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: enter image description here

有什么想法如何修复吗?


正在加载什么版本的 Az.Accounts?如果是 2.0.0-preview,DevOps 任务将失败。

您可以使用检查它Get-InstalledModule Az.Accounts -AllVersions

如果是这种情况使用:

Uninstall-Module -Name Az.Accounts -RequiredVersion 2.0.0-preview -AllowPrerelease

删除预览然后添加当前版本:

Install-Module -Name Az.Accounts -RequiredVersion 1.7.0

我不知道为什么要安装预览版,但它困扰了我一段时间......

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Docker 中运行 Azure DevOps 作业时出现“无法找到给定版本的模块 Az.Accounts”错误 的相关文章

随机推荐