Search code examples
c#azurebotframeworkdirect-line-botframeworkpersistent-storage

How to reinitialize UserState with new blobstorage outside Startup.cs class?


I have a front end webchat channel, I am sending an event activity which has a value(storage container name) to be sent on OnEventActivityAsync handler. How can I reconfigure the UserState initialized in startup.cs with a new storage name that I received from the event?

I am familiar with a concept of initializing UserState and AzureBlobStorage in Startup.cs but here I need to change the container name when OnEventActivityAsync is hit.


Solution

  • There is no official procedure to rename the container name out of the Startup.cs. But we have a small procedure to check regarding OnEventActivityAsync activity. Check out the links mentioned below to checkout the nearest procedure.

    Link1: https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.activityhandler?view=botbuilder-dotnet-stable

    Link2: https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.activityhandler.oneventactivityasync?view=botbuilder-dotnet-stable#microsoft-bot-builder-activityhandler-oneventactivityasync(microsoft-bot-builder-iturncontext((microsoft-bot-schema-ieventactivity))-system-threading-cancellationtoken)