我发现我们可以使用 azure 登录 cli 和
allow-no-subscriptions
参数。
所以我的问题是这个参数的目的是什么?尽管我们已经在存储库的秘密中定义了订阅 id,但当我们可以运行此命令时
az ad sp create-for-rbac --name "myApp" --role contributor \
--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \
--sdk-auth
因为它输出,订阅ID,租户ID,秘密ID,客户端ID。
令人惊讶的是,如果我通过 azure 门户创建应用程序注册,我会收到错误
Error: : No subscriptions found for ***.
Error: Az CLI Login failed. Please check the credentials and make sure az is installed on the runner. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows
尽管订阅 ID 在秘密中明确定义。
如果我只使用该参数
allow-no-subscriptions=false
那么我就没有问题了,它就像魅力一样。
要从本地计算机创建
rbac
,您需要升级 az 模块,并需要使用 az login
登录 Azure CLi
az upgrade
、az login
az ad sp create-for-rbac --name "myApp" --role contributor \
--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \
--sdk-auth
*服务原则映射到贡献者角色和订阅范围。 *
请查看以下截图
作为参考,请检查此 Az CLI 登录失败。请检查凭据并确保 az 已安装在运行器上