如何在 CI 管道中使用 Az CLI?
How to use Az CLI in a CI pipeline?
我不知道 az login 是如何工作的,但它必须保存凭据以供后续 az 命令使用。这意味着它不能按原样在 CI 管道中使用,其中多个并发管道可能 运行 在同一台构建机器上使用相同的系统帐户。
那么,我们如何在发布管道中使用 Az CLI?
(我知道 Az Azure DevOps 任务,但我无法让它工作)。
P.S.
我们使用本地 Azure DevOps Server 2019。
如果我没有正确理解你的问题,答案是 it's sometimes problematic to use multiple self-hosted agents for pipelines that use singleton tools on the same machine:
You might also run into problems if parallel build jobs are using the same singleton tool deployment, such as npm packages. For example, one build might update a dependency while another build is in the middle of using it, which could cause unreliable results and errors.
我想这可能会扩展到诸如尝试在同一系统帐户上进行单独的 az 会话之类的问题。虽然 - 我自己还没有尝试过 - 但我想知道你是否可以尝试将 az login
与服务主体客户端证书一起使用,如 here:
所示
az login --service-principal -u http://azure-cli-2016-08-05-14-31-15 -p ~/mycertfile.pem --tenant contoso.onmicrosoft.com
编辑: 找到这个 PR from this issue,所以看起来你可以 运行 同时进行会话。尽管我仍然不确定如果如前所述,您(例如)修改 Az CLI 工具本身会发生什么。
我不知道 az login 是如何工作的,但它必须保存凭据以供后续 az 命令使用。这意味着它不能按原样在 CI 管道中使用,其中多个并发管道可能 运行 在同一台构建机器上使用相同的系统帐户。
那么,我们如何在发布管道中使用 Az CLI?
(我知道 Az Azure DevOps 任务,但我无法让它工作)。
P.S.
我们使用本地 Azure DevOps Server 2019。
如果我没有正确理解你的问题,答案是 it's sometimes problematic to use multiple self-hosted agents for pipelines that use singleton tools on the same machine:
You might also run into problems if parallel build jobs are using the same singleton tool deployment, such as npm packages. For example, one build might update a dependency while another build is in the middle of using it, which could cause unreliable results and errors.
我想这可能会扩展到诸如尝试在同一系统帐户上进行单独的 az 会话之类的问题。虽然 - 我自己还没有尝试过 - 但我想知道你是否可以尝试将 az login
与服务主体客户端证书一起使用,如 here:
az login --service-principal -u http://azure-cli-2016-08-05-14-31-15 -p ~/mycertfile.pem --tenant contoso.onmicrosoft.com
编辑: 找到这个 PR from this issue,所以看起来你可以 运行 同时进行会话。尽管我仍然不确定如果如前所述,您(例如)修改 Az CLI 工具本身会发生什么。