Poznámka
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete sa skúsiť prihlásiť alebo zmeniť adresáre.
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete skúsiť zmeniť adresáre.
Storage is a critical component of Microsoft 365 Agents SDK. It lets agents persist conversation state, user data, and other information across sessions. The SDK supports various storage options, including:
- In-memory storage
- Azure Cosmos DB
- Azure Blob Storage
- Custom storage providers
Key storage options
The Agents SDK provides several built-in storage providers, each with its own use cases and benefits. You can choose the one that best fits your agent's needs. You can also implement your own custom storage provider.
Memory storage
- Suitable for testing and development purposes.
- Data is cleared when the agent restarts, so it's unsuitable for production.
- Data is only available on the web app instance, so it's unsuitable when running in a cluster.
Azure Cosmos DB
- A globally distributed, multimodel database ideal for production agents.
- Supports partitioned storage for scalability and performance.
Azure Blob Storage
- Optimized for storing unstructured data like text or binary files.
- Commonly used for agent state and transcript storage.
Custom storage options by implementing
IStorage
Using different storage providers
Memory storage
All samples use MemoryStorage. This storage is volatile and suitable for development and testing only. For production scenarios, use a more durable storage option like Azure Cosmos DB or Azure Blob Storage.
In Program.cs, register MemoryStorage:
builder.Services.AddSingleton<IStorage, MemoryStorage>();
Azure CosmosDb storage
Add a package dependency for
Microsoft.Agents.Storage.CosmosDb.In
Program.cs, add (or replace existing)IStorageregistration with:builder.Services.AddSingleton<IStorage>(sp => { var options = new CosmosDbPartitionedStorageOptions() { CosmosDbEndpoint = "your-cosmosdb-endpoint", DatabaseId = "your-database-id", ContainerId = "your-container-id", // Get a TokenCredential from your defined Connections TokenCredential = sp.GetService<IConnections>().GetConnection("ServiceConnection").GetTokenCredential() }; return new CosmosDbPartitionedStorage(options); });Learn more in
CosmosDbPartitionedStorageOptions.
Azure blob storage
Add a package dependency for
Microsoft.Agents.Storage.Blobs.In
Program.cs, add (or replace existing)IStorageregistration with:builder.Services.AddSingleton<IStorage>(sp => { // Get a TokenCredential from your defined Connections var tokenCredential = sp.GetService<IConnections>().GetConnection("ServiceConnection").GetTokenCredential(); return new BlobsStorage( new Uri("{{your-blobs-storage-endpoint}}/agent-state"), tokenCredential); });