小编Ale*_*kos的帖子

Microsoft Bot框架状态管理

我们正在更新我们的MBF机器人,以便在Azure Table Store中管理其状态.我们根据文档更改了代码以注册我们的表存储提供程序:

protected void Application_Start()
{
        GlobalConfiguration.Configure(WebApiConfig.Register);
        var builder = new ContainerBuilder();
        var store = new TableBotDataStore("...");

        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();

        var config = GlobalConfiguration.Configuration;

        var container = builder.Build();
        config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
}
Run Code Online (Sandbox Code Playgroud)

现在,在对话框中我们使用以下来存储和加载用户数据:

context.PrivateConversationData.SetValue<UserData>(UserDataRepositoryKey, userData);
Run Code Online (Sandbox Code Playgroud)

有趣的是,对话状态似乎得到维护,但我们看不到任何东西是我们的Azure表,我真的怀疑任何调用是否进入该存储.关于如何以正确的方式使用状态,文档非常不清楚.

题:

  1. 我们的容器注册是否正确?它应该在app_start还是应该为每个请求注册?

  2. 我们在对话期间使用正确的方法存储状态吗?

c# azure botframework

2
推荐指数
1
解决办法
560
查看次数

标签 统计

azure ×1

botframework ×1

c# ×1