A Cosmos DB storage library for Microsoft Agents
Project description
Microsoft Agents Storage - Cosmos DB
Azure Cosmos DB storage integration for Microsoft 365 Agents SDK. This library provides enterprise-grade persistent storage for conversation state, user data, and custom agent information using Azure Cosmos DB's globally distributed, multi-model database service.
This library implements the storage interface for the Microsoft 365 Agents SDK using Azure Cosmos DB as the backend. It provides automatic partitioning, global distribution, and low-latency access to your agent data. Perfect for production deployments requiring high availability, scalability, and multi-region support.
What is this?
This library is part of the Microsoft 365 Agents SDK for Python - a comprehensive framework for building enterprise-grade conversational AI agents. The SDK enables developers to create intelligent agents that work across multiple platforms including Microsoft Teams, M365 Copilot, Copilot Studio, and web chat, with support for third-party integrations like Slack, Facebook Messenger, and Twilio.
Release Notes
| Version | Date | Release Notes |
|---|---|---|
| 0.9.0 | 2026-04-15 | 0.9.0 Release Notes |
| 0.8.0 | 2026-02-23 | 0.8.0 Release Notes |
| 0.7.0 | 2026-01-21 | 0.7.0 Release Notes |
| 0.6.1 | 2025-12-01 | 0.6.1 Release Notes |
| 0.6.0 | 2025-11-18 | 0.6.0 Release Notes |
| 0.5.0 | 2025-10-22 | 0.5.0 Release Notes |
Packages Overview
We offer the following PyPI packages to create conversational experiences based on Agents:
Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:
| Package Name | PyPI Version | Description |
|---|---|---|
microsoft-agents-copilotstudio-client |
Direct to Engine client to interact with Agents created in CopilotStudio |
Why Cosmos DB?
- 🌍 Global distribution with multi-region writes
- ⚡ Single-digit millisecond latency
- 📈 Automatic and instant scalability
- 🔄 Multiple consistency models
- 💪 99.999% availability SLA
Installation
pip install microsoft-agents-storage-cosmos
Environment Setup
Local Development with Cosmos DB Emulator
Install and run the Azure Cosmos DB Emulator for local testing:
Download: Azure Cosmos DB Emulator
Best Practices
- Use Managed Identity in Production - Avoid storing auth keys in code or environment variables
- Initialize Once - Call
storage.initialize()during app startup, not per request - Batch Operations - Read/write multiple items together when possible
- Monitor RU Consumption - Use Azure Monitor to track Request Units usage
- Set Appropriate Throughput - Start with 400 RU/s, scale up based on metrics
- Use Session Consistency - Default consistency level for most scenarios
- Implement Retry Logic - Handle transient failures with exponential backoff
- Partition Wisely - Current implementation uses
/idpartitioning (automatic) - Enable Diagnostics - Configure Azure diagnostic logs for troubleshooting
- Test with Emulator - Use local emulator for development and testing
Key Classes Reference
CosmosDBStorage- Main storage implementation using Azure Cosmos DBCosmosDBStorageConfig- Configuration settings for connection and behaviorStoreItem- Base class for data models (inherit to create custom types)
Quick Links
Sample Applications
| Name | Description | README |
|---|---|---|
| Quickstart | Simplest agent | Quickstart |
| Auto Sign In | Simple OAuth agent using Graph and GitHub | auto-signin |
| OBO Authorization | OBO flow to access a Copilot Studio Agent | obo-authorization |
| Semantic Kernel Integration | A weather agent built with Semantic Kernel | semantic-kernel-multiturn |
| Streaming Agent | Streams OpenAI responses | azure-ai-streaming |
| Copilot Studio Client | Console app to consume a Copilot Studio Agent | copilotstudio-client |
| Cards Agent | Agent that uses rich cards to enhance conversation design | cards |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microsoft_agents_storage_cosmos-0.9.0.tar.gz.
File metadata
- Download URL: microsoft_agents_storage_cosmos-0.9.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
282ca898ae3986f381032b50c394a0b7cfe7be25e76b2cc53980edef2d59b484
|
|
| MD5 |
31fbb2fda7ea2b61e19cafb2c8ebf417
|
|
| BLAKE2b-256 |
d91311a2324081593441a979e99c777cb2fddf8248fc87161de3b73f8d5c6119
|
File details
Details for the file microsoft_agents_storage_cosmos-0.9.0-py3-none-any.whl.
File metadata
- Download URL: microsoft_agents_storage_cosmos-0.9.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0095440548784585f4be397752a2e85c1ecebae7603e5ea7fb02241c13331a8
|
|
| MD5 |
3f48461f80593884dd204a3690170cae
|
|
| BLAKE2b-256 |
60a90e4bc4a1cb5975d2d6d53d7ce0f856a6aef7809ff100f1e9ad6e5bc3ea70
|