CosmosDBChatExtensions.WithCosmosDBChatHistoryProviderUsingManagedIdentity Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Configures the agent to use Cosmos DB for message storage with managed identity authentication.
public static Microsoft.Agents.AI.ChatClientAgentOptions WithCosmosDBChatHistoryProviderUsingManagedIdentity(this Microsoft.Agents.AI.ChatClientAgentOptions options, string accountEndpoint, string databaseId, string containerId, Azure.Core.TokenCredential tokenCredential, Func<Microsoft.Agents.AI.AgentSession?,Microsoft.Agents.AI.CosmosChatHistoryProvider.State>? stateInitializer = default);
static member WithCosmosDBChatHistoryProviderUsingManagedIdentity : Microsoft.Agents.AI.ChatClientAgentOptions * string * string * string * Azure.Core.TokenCredential * Func<Microsoft.Agents.AI.AgentSession, Microsoft.Agents.AI.CosmosChatHistoryProvider.State> -> Microsoft.Agents.AI.ChatClientAgentOptions
<Extension()>
Public Function WithCosmosDBChatHistoryProviderUsingManagedIdentity (options As ChatClientAgentOptions, accountEndpoint As String, databaseId As String, containerId As String, tokenCredential As TokenCredential, Optional stateInitializer As Func(Of AgentSession, CosmosChatHistoryProvider.State) = Nothing) As ChatClientAgentOptions
Parameters
- options
- ChatClientAgentOptions
The chat client agent options to configure.
- accountEndpoint
- String
The Cosmos DB account endpoint URI.
- databaseId
- String
The identifier of the Cosmos DB database.
- containerId
- String
The identifier of the Cosmos DB container.
- tokenCredential
- TokenCredential
The TokenCredential to use for authentication (e.g., DefaultAzureCredential, ManagedIdentityCredential).
- stateInitializer
- Func<AgentSession,CosmosChatHistoryProvider.State>
An optional delegate that initializes the provider state on the first invocation, providing the conversation routing info (conversationId, tenantId, userId). When not provided, a new conversation ID is generated automatically.
Returns
The configured ChatClientAgentOptions.
Exceptions
Thrown when options or tokenCredential is null.
Thrown when any string parameter is null or whitespace.