gpt4 book ai didi

azure - 获取服务主体的 AZURE_CREDENTIALS

转载 作者:行者123 更新时间:2023-12-02 07:35:54 24 4
gpt4 key购买 nike

我已经创建了我的服务主体。

使用 GitHub,我需要完成以下所有参数。我的问题是我们在哪里以及如何找到每一个?

AZURE_CREDENTIALS :
{
"clientId": "XXX",
"clientSecret": "XXX",
"subscriptionId": "XXX",
"tenantId": "XXX",
"activeDirectoryEndpointUrl": "XXX",
"resourceManagerEndpointUrl": "XXX",
"activeDirectoryGraphResourceId": "XXX",
"sqlManagementEndpointUrl": "XXX",
"galleryEndpointUrl": "XXX",
"managementEndpointUrl": "XXX"
}

我已经在文档中看到,我们可以使用 CLI Azure 为新主体服务生成 JSON 文件:

az ad sp create-for-rbac `
--name "myApp" --role contributor `
--scopes /subscriptions/8baa642d-5109-4f1c-b935-401e5b215078/resourceGroups/rg-ai-recommender `
--sdk-auth

但我想使用现有的服务主体。

最佳答案

您可以多次运行该命令。

如果再次运行它,将会出现一条消息,内容如下:

az ad sp create-for-rbac --name TestPrincipal --role Contributor --sdk-auth
Found an existing application instance of "[existingId]". We will patch it
Creating 'Contributor' role assignment under scope '/subscriptions/[guid]'
Role assignment already exists.

The output includes credentials that you must protect. Be sure that you do not include these credentials in your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli
'name' property in the output is deprecated and will be removed in the future. Use 'appId' instead.
{
"clientId": "[existingId]",
"clientSecret": "[aNewSecret]",
"subscriptionId": "[subscriptionid]",
// all the other properties
}

当然,这将使您在其他存储库中使用的凭据无效,因此您也应该更新这些凭据。

恢复 secret 是不可能的,因为它是 secret 。

这样您就可以在多个存储库中使用相同的服务主体。

<小时/>

请记住,为不同的服务/部署创建新的服务主体可能是一种更安全的策略,因此您可以尽可能精细地分配角色。但这不是你的问题。

关于azure - 获取服务主体的 AZURE_CREDENTIALS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71394641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com