botbuilder-dotnet: Cannot use AzureTableStorage to persist ConversationState for dialogs
Trying to use Azure table storage to handle dialog state. File Storage works, but not Azure Storage.
When using this code for dialogs:
public class EchoBot : IBot
{
private readonly DialogSet dialogs;
public EchoBot()
{
dialogs = new DialogSet();
dialogs.Add("greetings", new WaterfallStep[]
{
async (dc, args, next) =>
{
// Prompt for the guest's name.
await dc.Prompt("textPrompt","What is your name?");
},
async (dc, args, next) =>
{
await dc.Context.SendActivity($"Hi {args["Text"]}!");
await dc.End();
}
});
// add the prompt, of type TextPrompt
dialogs.Add("textPrompt", new Microsoft.Bot.Builder.Dialogs.TextPrompt());
}
public async Task OnTurn(ITurnContext context)
{
// This bot is only handling Messages
if (context.Activity.Type == ActivityTypes.Message)
{
// Dialogs
var state = ConversationState<Dictionary<string, object>>.Get(context);
var dc = dialogs.CreateContext(context, state);
await dc.Continue();
if (!context.Responded)
{
await dc.Begin("greetings");
}
}
}
}
In startup.cs this works:
var dataStore = new FileStorage("c:/temp");
options.Middleware.Add(new ConversationState<Dictionary<string, object>>(dataStore));
But this doesn’t
IStorage dataStore =
new Microsoft.Bot.Builder.Azure.AzureTableStorage("DefaultEndpointsProtocol=https;AccountName=aihelpwebsitestorage;AccountKey=**account Key**;EndpointSuffix=core.windows.net","helloworldbotsimpledialog");
options.Middleware.Add(new ConversationState<Dictionary<string, object>>(dataStore));
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (6 by maintainers)
I updated my article to use Cosmos DB http://aihelpwebsite.com/Blog/EntryId/1031/Saving-User-and-Conversation-Data-MS-Bot-Framework-V4-Preview-Edition
It’d definitely be nice to still use table storage for persistence even if it gets a not-great-for-production tag (is it’s latency a problem?) or something. Unless I’m misreading it, for a not-used-a-lot bot, bottom-end price point for a Cosmos instance is $25/mo, while azure table storage is trivial.
Of course, given the extensiblity goal there, writing it myself for apps probably won’t be hard anyway.
@ADefWebserver we have decided to deprecate table store and replace it with blob storage, cosmosDB, and memory storage as our storage providers.
What must we do to encourage the team to maintain Azure Storage account implementations?
CosmosDB is considerably more expensive than table or blob storage, and I would strongly disagree with any claims that it is not fine for production (VMs use storage accounts)
From what I have read, the performance cosmos offers comes at a high cost, and the value just isn’t there.
I certainly hope this decision is not financially motivated…
@drub0y - Thanks for the heads up. I will update the code to use CosmosDbStorage for now. This is how pre-release software goes, I’m used to it.
hey @adefwebserver, thanks for reporting this and supplying a repro. Can I ask you to please include the full details of the exception being thrown (i.e.
$exception.ToString()
) as well? Might help reach a resolution a little faster.