node.js - 为 BotFramework v4 使用 TableStorage
问题描述
目前我已经使用 Azure Cosmos DB 实现了 Bots。我使用状态访问器管理状态数据(用户状态、对话状态)。
我如何使用它的示例:
// Use AutosaveStateMiddleware
adapter.use(new AutoSaveStateMiddleware(conversationState));
adapter.use(new AutoSaveStateMiddleware(userState));
// Read State from DB
const conversationData = await this.conversationDataAccessor.get(turnContext, {});
const user = await this.userDataAccessor.get(turnContext, {});
// Manipulate state
conversationData.roundCounter = 1;
userData.name = "John Doe";
// Save to cache
await this.userDataAccessor.set(turnContext, user);
await this.conversationDataAccessor.set(turnContext, conversationData);
// Save changes to DB (persistent)
await this.conversationState.saveChanges(turnContext);
await this.userState.saveChanges(turnContext);
我考虑改用表存储解决方案,因为它比 Cosmos DB 便宜得多。
不幸的是,我只找到了BotFramework v3 的教程。
有没有办法以类似的方式使用表存储?如果是这样,怎么做?
谢谢!
解决方案
设置数据库的一些额外提示:
文章中的语法对我不起作用。我改用这个:
const { BlobStorage } = require('botbuilder-azure');
// Add Blobstorage
const memoryStorage = new BlobStorage({
containerName: 'CONTAINERNAME',
storageAccountOrConnectionString: 'CONNECTIONSTRING',
})
您可以在 Azure 上的存储资源中的“密钥”下找到信息。
推荐阅读
- android - 如何在 Flutter 中访问 DocumentReference 数组?
- reactjs - 在 JSON 数据中的可选字段的情况下找不到 AG-GRID 字段
- python - 登录 admin 后 Django 开发服务器停止
- css - Css负z-index在另一个元素内不起作用
- c# - 如何使用自己的模型映射 REST 实体
- ruby-on-rails - 模型中未定义的模块方法
- azure - 如何找到azure静态网站的DNS A记录?
- algorithm - 游戏拼图,两个玩家玩替换硬币价值的游戏
- mysql - MySQL - 小int的where条件
- applescript - 一键转发标记的消息。苹果脚本