How to manage bot state without persisting data on disk in deployment

Majid Komeili 20 Reputation points
2025-07-30T18:58:31.1733333+00:00

I'm using the Microsoft Bot Framework SDK (Node.js) and ran into a problem after deploying to Azure. In development, I used MemoryStorage, which worked fine. But in production, the bot started losing state mid-conversation, likely due to restarts. I switched to BlobStorage, which fixed the issue, but now user data is being stored on Azure — and that’s a problem for us due to privacy constraints. I’m looking for a way to keep the bot working reliably without storing any user or conversation data on Azure. Is there a supported way to do this?

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
{count} votes

Accepted answer
  1. Ravada Shivaprasad 920 Reputation points Microsoft External Staff Moderator
    2025-07-30T21:44:05.69+00:00

    Hi Majid Komeili

    The Microsoft Bot Framework SDK provides a flexible architecture for managing bot state, structured around three core layers: the storage layer, which physically stores data; the state management layer, which handles read/write operations and caching; and state property accessors, which provide methods to interact with specific state properties. This modular design allows developers to swap out the storage layer without disrupting the rest of the bot’s logic, making it ideal for privacy-sensitive deployments.

    For organizations with strict data sovereignty or compliance requirements, Redis is a highly recommended alternative to Azure Blob Storage. Redis offers high-performance, in-memory data storage with built-in Time-To-Live (TTL) support, allowing you to automatically expire state data after a defined period. The Bot Framework SDK includes a RedisStorage class that can be configured with custom hostnames, ports, and credentials, giving you full control over where and how data is stored. This setup ensures that sensitive user data remains within your infrastructure while maintaining the reliability and scalability benefits of persistent storage.

    Alternatively, for maximum flexibility, you can implement a custom storage adapter by creating a class that conforms to the Bot Framework’s IStorage interface. This involves implementing three core methods: read, write, and delete. A custom adapter allows you to integrate with any backend system—on-premises databases, encrypted local files, or even ephemeral in-memory caches—tailored to your organization’s privacy and compliance policies.

    Both Redis and custom storage adapters preserve the bot’s ability to maintain state across restarts and scaling events, which is essential for production reliability. They also support advanced features like error handling, retry logic, and monitoring, ensuring robust bot behavior without compromising user privacy.

    Reference Links : Implement custom storage for your bot

    Hope it helps

    Thank you

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.