部署中的 az 登录问题

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

我在 Octopus 中运行 bash 脚本来上传 B2C 策略 xml。

使用时:

az login --service-principal --username $client_id --password $client_secret --tenant $tenant_id --allow-no-subscriptions

我收到错误:参数 --username/-u:需要一个参数

更新使用 =:

az login --service-principal --username=$client_id --password=$client_secret --tenant=$tenant_id --allow-no-subscriptions

现在我收到错误:错误:无法解析租户''。

在上述两种情况下,尽管出现错误,但仍能够登录。但是有没有办法消除错误呢?

azure-cli octopus-deploy
1个回答
0
投票

最初,我遇到了同样的错误:

az login --service-principal --username $client_id --password $client_secret --tenant $tenant_id --allow-no-subscriptions

enter image description here

az login --service-principal --username=$client_id --password=$client_secret --tenant=$tenant_id --allow-no-subscriptions

enter image description here

如果您没有声明变量,通常会发生该错误。因此,我同意 @Joel Brewer 检查变量是否是通过执行

echo $client_id
来检查它是否返回值来声明的。

要解决该错误,请确保在连接到

az
之前声明变量,如下所示:

client_id="ClientID"
client_secret="ClientSecret"
tenant_id="TenantID"

az login --service-principal --username $client_id --password $client_secret --tenant $tenant_id --allow-no-subscriptions

enter image description here

当我运行

echo $client_id
时,它会返回值并类似地检查其他变量:

enter image description here

如果问题仍然存在,请用引号将变量括起来,如下所示,然后尝试:

az login --service-principal --username="$client_id" --password="$client_secret" --tenant="$tenant_id" --allow-no-subscriptions

enter image description here

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