【问题标题】:Use TableStorage for BotFramework v4为 Bot Framework v4 使用表存储
【发布时间】:2023-04-01 06:35:01
【问题描述】:

目前我已经使用 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 找到了 tutorial。

有没有办法以类似的方式使用表存储?如果有,怎么做?

谢谢!

【问题讨论】:

    标签: node.js database azure botframework azure-table-storage


    【解决方案1】:

    设置数据库的一些额外提示:

    文章中的语法对我不起作用。我改用这个:

    const { BlobStorage } = require('botbuilder-azure');
    
    // Add Blobstorage
    const memoryStorage = new BlobStorage({
       containerName: 'CONTAINERNAME',
       storageAccountOrConnectionString: 'CONNECTIONSTRING',
    })
    

    您可以在 Azure 的存储资源中的“密钥”下找到信息。

    【讨论】:

      猜你喜欢
      • 2019-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-07
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 2019-08-23
      相关资源
      最近更新 更多