botframework - 我的 global.asax.cs 文件中是否缺少用于连接到 Azure Cosmos 的依赖项?
问题描述
我是 Bot Framework 的新手,并且符合最佳实践,我一直在尝试连接到 Azure Cosmos DB 来管理状态数据。
下面的代码编译没有任何问题,但是当我尝试在 Azure 的测试 Web Bot 屏幕中测试机器人时,它会向 Bot 授权,但它没有连接,所以我无法测试数据库连接。
我一直在使用 SDK 的 v3 开发 Bot,并尝试通过删除最初关于 Cosmos DB 的注释行来修改开箱即用,但编译失败,所以一直在修改下面的代码,它可以编译,但是似乎没有启动机器人。
using System;
using Autofac;
using System.Web.Http;
using System.Configuration;
using System.Reflection;
using Microsoft.Bot.Builder.Azure;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Internals;
using Microsoft.Bot.Connector;
namespace SimpleEchoBot
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// Bot Storage: This is a great spot to register the private state storage for your bot.
// We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
// For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
var uri = new Uri(ConfigurationManager.AppSettings["uri"]);
var key = ConfigurationManager.AppSettings["accesskey"];
var store = new DocumentDbBotDataStore(uri, key);
Conversation.UpdateContainer(
builder =>
{
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
builder.Register(c => new CachingBotDataStore(store, CachingBotDataStoreConsistencyPolicy.ETagBasedConsistency))
.As<IBotDataStore<BotData>>()
.AsSelf()
.InstancePerLifetimeScope();
});
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
}
我希望输出是 Bot 初始化,但没有这样做。
解决方案
推荐阅读
- r - 如何使用 group_by() 显示最早日期
- php - 使用 PHP 从 XML youtube 视频中获取视频 ID
- microsoft-graph-api - 错误网关 502:使用 Graph beta Api 将成员添加到团队
- java - removeNull() 导致我的数组出现问题
- flutter - 将尾随小部件推送到 Flutter Navigation Rail 的底部
- java - 从另一个实体而不是从数据库中删除实体
- python - 如何在 Python 中不使用 JES 函数水平翻转图像
- python - Pandas 比较数据帧并根据另一个数据帧中的相似行数更改列值
- pytorch - 如何在 pytorch 中正确保存 torch.nn.Sequential 模型?
- python-3.x - 如何在 Django 上使用 modelformset_factory 进行更新