gpt4 book ai didi

.net - 如何创建 MSA ID 和密码以使用 SDK 创建 Azure Bot 服务

转载 作者:行者123 更新时间:2023-12-03 01:42:42 25 4
gpt4 key购买 nike

我想基于数据动态创建 Azure 机器人服务。为了创建 Bot 服务,我使用了 Microsoft.Azure.Management.BotService NuGet 包。

用于创建,但我需要输入 MSA 应用程序 ID 和密码。目前,我正在从 https://apps.dev.microsoft.com/#/appList 手动创建
但是有没有办法动态创建这个App并获取Id/Passwords?

// Create Bot client
AzureBotServiceClient botServiceClient = new AzureBotServiceClient(credentials);
botServiceClient.TenantId = credentials.TenantId;
botServiceClient.SubscriptionId = credentials.DefaultSubscriptionId;

// Create Bot
Bot bot = new Bot
{
Location = "centralus",
Properties = new BotProperties
{
Description = "Description of New Bot",
DisplayName = "MyNewBotCreatedFromConsole",
Endpoint = "https://xyz.azurewebsites.net/api/Messages",
Kind = "sdk",
Sku = new Sku(SkuName.F0, SkuTier.Free),
Location = "centralus",
MsaAppId = "???",
MsaAppPassword = "???"
},
};
botServiceClient.Bots.Create(resourceName, resourceName, bot);

注意:此包已包含 GetOrCreateMsaAppId() 但它是私有(private)的

最佳答案

How to create MSA Id & Password for creating Azure Bot service using SDK

如果您想创建 Azure AD 应用程序并且 Rest API 是可以接受的,您可以使用 Microsoft graph create application API .

https://graph.microsoft.com/beta/applications

Important: APIs under the /beta version in Microsoft Graph are in preview and are subject to change. Use of these APIs in production applications is not supported.

我用 Microsoft Graph explorer 进行测试,它对我来说工作正常。

请求正文格式

{
"allowPublicClient": true,
"displayName": "tomsdk",
passwordCredentials:
[{
"customKeyIdentifier": null,
"endDateTime": "2019-07-01T00:00:00Z",
"keyId": "b5b2920e-a47c-43b7-91ef-25ae96fddddd", //Guid
"startDateTime": "2018-07-01T00:00:00Z",
"secretText": "123QWER!@#$qwweerzcxvc", //password, you could set it by yourself.
"hint": "string"
}]
}

测试结果:

enter image description here

关于.net - 如何创建 MSA ID 和密码以使用 SDK 创建 Azure Bot 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51353442/

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