Botbuilder身份验证多租户
我想创建Microsoft botbuilder 此教程之后。但是与V3相比,它似乎很复杂。(顺便说一句:启动一个带有3个身份验证的教程,覆盖本文的75%不是一个好兆头),
所以我遵循Echobot样本(我选择了多材料,因为我的服务器在外面,而且似乎是大多数涵盖):
const credentialsFactory = new BotBuilder.ConfigurationServiceClientCredentialFactory({
MicrosoftAppId: '***',
MicrosoftAppPassword: '***',
MicrosoftAppType: 'MultiTenant',
});
const botFrameworkAuthentication = BotBuilder.createBotFrameworkAuthenticationFromConfiguration(null, credentialsFactory);
const onTurnErrorHandler = async (context, error) => { /* for errors */ }
const adapter = new BotBuilder.CloudAdapter(botFrameworkAuthentication);
adapter.onTurnError = onTurnErrorHandler;
问题:
- 如何测试一切都起作用?
iSvalidAppid()
和isAuthenticationDisabled()
是唯一可用的方法,似乎还可以。 - 如何获得
microsoftappPassword
?根据文档,我必须单击管理,然后创建一个value/secret
对。我应该使用value
吗?还是秘密
?为什么没有一个名为密码
?无论如何,没有任何作用...
要测试它是否有效,我遵循示例:
- http post endpoint(带有node-red)
- 端点
- 声明Azure Portal Bot配置中的
设置 接收消息,然后尝试进行一些身份验证/parisng(我假设):
await adapter.process(msg.req, msg.res, (context) => {
/* do some stuff */
});
但是它会出现非常明确的错误:
Error: 1 validation issue(s)
Issue #0: custom_error at [[root]]
Response
我认为,错误与身份验证问题有关,因为我不明白什么/如何设置密码。我想我必须通过此CloudAdapter
进行解析上下文
并能够发送消息。
编辑07/05/2022:
编辑12/05/2022:
使用Curl我设法验证了appid和apppassword(秘密的恒星)的值(由星星隐藏)。
Botbuilder正在混合通信堆栈(HTTP / Websocket)和逻辑堆栈(转向对话)。我认为这是一个不好的习惯,但我管理一个解决方法:
- 我使用
botframeworkAdapter
而不是cloudAdpater
- 我调用
adapter.processactivity()
而不是<<<代码> adapter.process()
适配器仍然希望结束()请求并设置不推荐的值,但在node-red中起作用。 上下文
处理所有需要多次调用sendActivity()
的要求。
I want to create Microsoft BotBuilder following this tutorial. But it seems SO complicated compared to v3.(BTW: starting a tutorial with 3 authentications that cover 75% of the article is not a good sign)
So I follow the EchoBot sample (I chose MultiTenant because my server is outside AND it seems the most covered):
const credentialsFactory = new BotBuilder.ConfigurationServiceClientCredentialFactory({
MicrosoftAppId: '***',
MicrosoftAppPassword: '***',
MicrosoftAppType: 'MultiTenant',
});
const botFrameworkAuthentication = BotBuilder.createBotFrameworkAuthenticationFromConfiguration(null, credentialsFactory);
const onTurnErrorHandler = async (context, error) => { /* for errors */ }
const adapter = new BotBuilder.CloudAdapter(botFrameworkAuthentication);
adapter.onTurnError = onTurnErrorHandler;
Questions:
- How do I test everything is working ?
isValidAppId()
andisAuthenticationDisabled()
are the only available method and seems OK. - How do I get
MicrosoftAppPassword
? According to the documentation I have to click manage, then create avalue/secret
pair. Should I usevalue
? orsecret
? Why none is namedpassword
? Anyway none works ...
To test if it works, I follow the sample:
- setup an HTTP POST Endpoint (with Node-RED)
- declare the endpoint in Azure Portal Bot Configuration
- go to webchat to test
I correctly receive the Messages then try to do some authentication/parisng (I assume) :
await adapter.process(msg.req, msg.res, (context) => {
/* do some stuff */
});
But it fails with a very explicit error :
Error: 1 validation issue(s)
Issue #0: custom_error at [[root]]
Response
I think, the errors is related to an authentication issue, since I don't understand what/how to set the password. I guess I have to go through this CloudAdapter
in order to get a parsed context
and be able to send messages.
EDIT 07/05/2022:
I click "Manage" but where is the AppPassword ?
EDIT 12/05/2022:
Using cURL I manage to validate the appID and appPassword (the value (hidden by stars) of the secret).
BotBuilder is mixing the Communication Stack (HTTP / WebSocket) and the Logic stack (Turn Conversation). I think it's a bad habbit but I manage a workaround:
- I use a
BotFrameworkAdapter
instead ofCloudAdpater
- I call
adapter.processActivity()
instead ofadapter.process()
The adapter still want to end() the request and set deprecated values but it works in Node-RED. The context
handle all the requirement to call sendActivity()
anywhere multiple times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要回答您的情况下的第二个问题,请通过链接: https://learn.microsoft.com/en-us/azure/azure/bot-service/bot-service/bot-service-service-service-service-quick,start-registart-registration-emistration?view = azure -bot-service-4.0&amp; tabs =多端
在您的情况下回答第一个问题,请检查禁用并使身份验证测试应用程序: https:// https://learn.microsoft .com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp
To answer second question in your case, kindly go through the link :https://learn.microsoft.com/en-us/azure/bot-service/bot-service-quickstart-registration?view=azure-bot-service-4.0&tabs=multitenant
To answer the first question in your case, kindly check disabling and enabling the authentication to test the app: https://learn.microsoft.com/en-us/azure/bot-service/bot-service-troubleshoot-authentication-problems?view=azure-bot-service-4.0&tabs=csharp
至于获得密码,当您创建新的多租户Azure机器人资源时,App密码将进入与之搭配的Azure密钥库中。 Appid和AppPassword由Azure随机生成。您可以从正确资源组的Azure门户中的密钥库中获取它们。
如果要使用CLI手动创建资源并定义您自己的密码,则可以将此文档页面用于部署bot 。确保选择正确的选项卡。我在一个新的资源组中为上述链接提供了预选的C#和多人租户。
单人租户是为了限制机器人与同一租户内的Azure资源的连接,而用户分配的托管身份是您要在机器人资源上使用Azure托管身份,而不是为每个资源提供密码。
您应该能够简单地将附录和AppPassword添加到Echo Bot示例中并部署它。
As far as getting the password goes, when you create a new Multi Tenant Azure Bot resource, the app password goes into the Azure Key Vault created alongside it. The AppId and AppPassword are randomly generated by Azure. You can get them from the key vault in the Azure portal in the correct resource group.
If you want to create a resource manually using the CLI and define your own password, you can use this docs page for deploying a bot. Make sure you select the correct tabs. I have pre-selected C# and Multi Tenant in a new resource group for the above link.
Single Tenant is for limiting your bot's connections to Azure resources within the same tenant, and a User Assigned Managed Identity is if you want to make use of an Azure Managed Identity across the bot's resources instead of having a password for each resource.
You should be able to simply add the AppId and AppPassword to the echo bot sample and deploy it.