22
33using System ;
44using System . Diagnostics . CodeAnalysis ;
5- using Azure . Identity ;
5+ using Azure . Core ;
66using Microsoft . Agents . AI . Workflows . Checkpointing ;
77using Microsoft . Azure . Cosmos ;
88
@@ -52,14 +52,17 @@ public static CosmosCheckpointStore CreateCheckpointStore(
5252 /// <param name="accountEndpoint">The Cosmos DB account endpoint URI.</param>
5353 /// <param name="databaseId">The identifier of the Cosmos DB database.</param>
5454 /// <param name="containerId">The identifier of the Cosmos DB container.</param>
55+ /// <param name="tokenCredential">The TokenCredential to use for authentication (e.g., DefaultAzureCredential, ManagedIdentityCredential).</param>
5556 /// <returns>A new instance of <see cref="CosmosCheckpointStore"/>.</returns>
5657 /// <exception cref="ArgumentException">Thrown when any string parameter is null or whitespace.</exception>
58+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="tokenCredential"/> is null.</exception>
5759 [ RequiresUnreferencedCode ( "The CosmosCheckpointStore uses JSON serialization which is incompatible with trimming." ) ]
5860 [ RequiresDynamicCode ( "The CosmosCheckpointStore uses JSON serialization which is incompatible with NativeAOT." ) ]
5961 public static CosmosCheckpointStore CreateCheckpointStoreUsingManagedIdentity (
6062 string accountEndpoint ,
6163 string databaseId ,
62- string containerId )
64+ string containerId ,
65+ TokenCredential tokenCredential )
6366 {
6467 if ( string . IsNullOrWhiteSpace ( accountEndpoint ) )
6568 {
@@ -76,7 +79,12 @@ public static CosmosCheckpointStore CreateCheckpointStoreUsingManagedIdentity(
7679 throw new ArgumentException ( "Cannot be null or whitespace" , nameof ( containerId ) ) ;
7780 }
7881
79- return new CosmosCheckpointStore ( accountEndpoint , new DefaultAzureCredential ( ) , databaseId , containerId ) ;
82+ if ( tokenCredential is null )
83+ {
84+ throw new ArgumentNullException ( nameof ( tokenCredential ) ) ;
85+ }
86+
87+ return new CosmosCheckpointStore ( accountEndpoint , tokenCredential , databaseId , containerId ) ;
8088 }
8189
8290 /// <summary>
@@ -154,14 +162,17 @@ public static CosmosCheckpointStore<T> CreateCheckpointStore<T>(
154162 /// <param name="accountEndpoint">The Cosmos DB account endpoint URI.</param>
155163 /// <param name="databaseId">The identifier of the Cosmos DB database.</param>
156164 /// <param name="containerId">The identifier of the Cosmos DB container.</param>
165+ /// <param name="tokenCredential">The TokenCredential to use for authentication (e.g., DefaultAzureCredential, ManagedIdentityCredential).</param>
157166 /// <returns>A new instance of <see cref="CosmosCheckpointStore{T}"/>.</returns>
158167 /// <exception cref="ArgumentException">Thrown when any string parameter is null or whitespace.</exception>
168+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="tokenCredential"/> is null.</exception>
159169 [ RequiresUnreferencedCode ( "The CosmosCheckpointStore uses JSON serialization which is incompatible with trimming." ) ]
160170 [ RequiresDynamicCode ( "The CosmosCheckpointStore uses JSON serialization which is incompatible with NativeAOT." ) ]
161171 public static CosmosCheckpointStore < T > CreateCheckpointStoreUsingManagedIdentity < T > (
162172 string accountEndpoint ,
163173 string databaseId ,
164- string containerId )
174+ string containerId ,
175+ TokenCredential tokenCredential )
165176 {
166177 if ( string . IsNullOrWhiteSpace ( accountEndpoint ) )
167178 {
@@ -178,7 +189,12 @@ public static CosmosCheckpointStore<T> CreateCheckpointStoreUsingManagedIdentity
178189 throw new ArgumentException ( "Cannot be null or whitespace" , nameof ( containerId ) ) ;
179190 }
180191
181- return new CosmosCheckpointStore < T > ( accountEndpoint , new DefaultAzureCredential ( ) , databaseId , containerId ) ;
192+ if ( tokenCredential is null )
193+ {
194+ throw new ArgumentNullException ( nameof ( tokenCredential ) ) ;
195+ }
196+
197+ return new CosmosCheckpointStore < T > ( accountEndpoint , tokenCredential , databaseId , containerId ) ;
182198 }
183199
184200 /// <summary>
0 commit comments