Please install this package via pip:
pip install agent-framework-azure-cosmos --preThe Azure Cosmos DB integration provides CosmosHistoryProvider for persistent conversation history storage.
from azure.identity.aio import DefaultAzureCredential
from agent_framework.azure import CosmosHistoryProvider
provider = CosmosHistoryProvider(
endpoint="https://<account>.documents.azure.com:443/",
credential=DefaultAzureCredential(),
database_name="agent-framework",
container_name="chat-history",
)Credentials follow the same pattern used by other Azure connectors in the repository:
- Pass a credential object (for example
DefaultAzureCredential) - Or pass a key string directly
- Or set
AZURE_COSMOS_KEYin the environment
Container naming behavior:
- Container name is configured on the provider (
container_nameorAZURE_COSMOS_CONTAINER_NAME) session_idis used as the Cosmos partition key for reads/writes
See the conversation samples for runnable examples, including
cosmos_history_provider.py.
from agent_framework.azure import CosmosHistoryProvider
# or directly:
from agent_framework_azure_cosmos import CosmosHistoryProvider