dockerfile 无法通信 azure 存储库

问题描述 投票:0回答:1

我们已经内置了 Azure DevOps,并且它正在 Azure 应用服务中运行。 尝试在构建上制作 Docker 镜像。 无法访问我们的私有 Azure 存储库。 我们通过 Docker 和 Azure Repo 面临一些阻塞问题。

enter image description here

docker azure-devops dockerfile
1个回答
0
投票

错误 NU1301:无法加载源的服务索引 https://pkgs.dev.azure.com/MyOrg/MyProj/_packaging/MyFeed/nuget/v3/index.json

从错误消息来看,问题原因是Azure Artifacts Nuget源无法进行身份验证。

要解决此问题,您可以参考以下步骤将Credentials添加到nuget.config文件中进行身份验证。

1.使用 dotnet cli 将凭据添加到项目 nuget.config 中的 Nuget 源。然后在构建参数中传递个人访问令牌(PAT)(例如 --build-arg PAT=$PAT):

ARG PAT
RUN dotnet nuget add source "your-source-url" --name "source-name" --username "xx" --password "$PAT" -ConfigFile Source/Nuget.config --store-password-in-clear-text

2.将docker文件中的nuget.config复制到与.csproj文件相同路径。

例如:

ARG PAT
COPY *.csproj .
COPY ./nuget.config .
RUN dotnet nuget add source "your-source-url" --name "source-name" --username "xx" --password "$PAT" -ConfigFile ./Nuget.config --store-password-in-clear-text
RUN dotnet restore

或者您可以使用工件凭据提供程序来验证 Azure Nuget Feed:工件凭据提供程序 .

© www.soinside.com 2019 - 2024. All rights reserved.