Skip to main content

A Cosmos DB storage library for Microsoft Agents

Project description

Microsoft Agents Storage - Cosmos DB

PyPI version

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.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:

Package Name PyPI Version Description
microsoft-agents-activity PyPI Types and validators implementing the Activity protocol spec.
microsoft-agents-hosting-core PyPI Core library for Microsoft Agents hosting.
microsoft-agents-hosting-aiohttp PyPI Configures aiohttp to run the Agent.
microsoft-agents-hosting-teams PyPI Provides classes to host an Agent for Teams.
microsoft-agents-storage-blob PyPI Extension to use Azure Blob as storage.
microsoft-agents-storage-cosmos PyPI Extension to use CosmosDB as storage.
microsoft-agents-authentication-msal PyPI MSAL-based authentication for Microsoft Agents.

Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:

Package Name PyPI Version Description
microsoft-agents-copilotstudio-client PyPI 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

  1. Use Managed Identity in Production - Avoid storing auth keys in code or environment variables
  2. Initialize Once - Call storage.initialize() during app startup, not per request
  3. Batch Operations - Read/write multiple items together when possible
  4. Monitor RU Consumption - Use Azure Monitor to track Request Units usage
  5. Set Appropriate Throughput - Start with 400 RU/s, scale up based on metrics
  6. Use Session Consistency - Default consistency level for most scenarios
  7. Implement Retry Logic - Handle transient failures with exponential backoff
  8. Partition Wisely - Current implementation uses /id partitioning (automatic)
  9. Enable Diagnostics - Configure Azure diagnostic logs for troubleshooting
  10. Test with Emulator - Use local emulator for development and testing

Key Classes Reference

  • CosmosDBStorage - Main storage implementation using Azure Cosmos DB
  • CosmosDBStorageConfig - Configuration settings for connection and behavior
  • StoreItem - 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

microsoft_agents_storage_cosmos-0.9.0.dev9.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file microsoft_agents_storage_cosmos-0.9.0.dev9.tar.gz.

File metadata

File hashes

Hashes for microsoft_agents_storage_cosmos-0.9.0.dev9.tar.gz
Algorithm Hash digest
SHA256 b8c5cacb436e80329dfaddb2679636dd988f545aba8ab9f605d47598f45619b0
MD5 8d84ecd6922687a4c662ac7e54df07e4
BLAKE2b-256 a25c8cccf352119a719ca0f481eea4bbd61bdb177576879a07b0c325296a8aa9

See more details on using hashes here.

File details

Details for the file microsoft_agents_storage_cosmos-0.9.0.dev9-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_agents_storage_cosmos-0.9.0.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 fb74cb1e6ebf7dd524177d5bbe58aacd3a2d759c596bd5d5f4afd3552bf13929
MD5 75efd7d90a7f0da23b93f859d0ed3c9b
BLAKE2b-256 86cc5e3208d992d5eabe81a4ce393cdb4c99dcc0a6997237b27e468f47f90b2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page