Fla*_*ito 12 azure ansible azure-cli azure-service-principal
我正在尝试让我的 ansible 脚本通过 azure cli 登录到 azure。由于某些原因,我不允许使用 ansible azure 包。我必须使用 shell 并直接从那里调用命令。
一般来说,我对 Azure 还很陌生,所以所有这些租户、服务主体等仍然是我没有完全掌握的概念。
我一直在检查官方文档。我已经为其创建了一个应用程序注册(名为 ansible_test)。我得到了我需要的一切,包括秘密。然后我将命令称为:
az login --service-principal -u $AZURE_SERVICE_PRINCIPAL_NAME -p $AZURE_SECRET --tenant $AZURE_TENANT
Run Code Online (Sandbox Code Playgroud)
在哪里:
$AZURE_SERVICE_PRINCIPAL_NAME = ansible_test
$AZURE_SECRET = ${The one that I've defined via Certificates & secrets section in the app registration}
$AZURE_TENANT = ${The azure tenant that I find in the app registration}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Get Token request returned http error: 400 and server response: {"error":"unauthorized_client","error_description":"AADSTS700016: Application with identifier 'ansible_test' was not found in the directory '${AZURE_TENANT}(Blurred because I'm not sure this is something secret or not)'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.
Run Code Online (Sandbox Code Playgroud)
据我了解,我找错了租客。但我得到的和我从应用程序注册中得到的一模一样。我已经用头撞这堵墙有一段时间了。我尝试了很多其他方法,但似乎不起作用。
在这张图片中,我试图表明我确实已经创建了应用程序注册(据我所知,它是一个服务主体)。我模糊了 id 只是出于无知,无论它们是否是私有的。
我做错了什么?我真的无法理解错误的根源......
juu*_*nas 12
服务主体的用户名是其应用程序(客户端)ID,因此您需要使用它而不是应用程序名称。
它在幕后使用客户端凭据流来获取令牌,这需要客户端 ID、租户 ID + 客户端密钥/客户端证书进行身份验证。
小智 8
使用以下命令,在运行该命令之前,请确保定义变量。
az login --service-principal -u ${app_id} -p ${password} --tenant ${tenant_id}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40379 次 |
| 最近记录: |