@@ -16,15 +16,37 @@ public CosmosDbContainer(CosmosDbConfiguration configuration)
1616 /// <summary>
1717 /// Gets the CosmosDb connection string.
1818 /// </summary>
19+ /// <remarks>
20+ /// The connection string includes the emulator account endpoint and
21+ /// the default account key permitted by the emulator, which is also
22+ /// available through <see cref="CosmosDbBuilder.DefaultAccountKey" />.
23+ /// </remarks>
1924 /// <returns>The CosmosDb connection string.</returns>
2025 public string GetConnectionString ( )
2126 {
2227 var properties = new Dictionary < string , string > ( ) ;
23- properties . Add ( "AccountEndpoint" , new UriBuilder ( Uri . UriSchemeHttp , Hostname , GetMappedPublicPort ( CosmosDbBuilder . CosmosDbPort ) ) . ToString ( ) ) ;
28+ properties . Add ( "AccountEndpoint" , GetAccountEndpoint ( ) ) ;
2429 properties . Add ( "AccountKey" , CosmosDbBuilder . DefaultAccountKey ) ;
2530 return string . Join ( ";" , properties . Select ( property => string . Join ( "=" , property . Key , property . Value ) ) ) ;
2631 }
2732
33+ /// <summary>
34+ /// Gets the CosmosDb account endpoint.
35+ /// </summary>
36+ /// <remarks>
37+ /// This returns only the account endpoint. Use
38+ /// <see cref="GetConnectionString" /> when you also need the default
39+ /// account key permitted by the emulator. For more information, see
40+ /// <see href="https://learn.microsoft.com/en-us/azure/cosmos-db/emulator">
41+ /// Azure Cosmos DB emulator documentation
42+ /// </see>.
43+ /// </remarks>
44+ /// <returns>The CosmosDb account endpoint.</returns>
45+ public string GetAccountEndpoint ( )
46+ {
47+ return new UriBuilder ( Uri . UriSchemeHttp , Hostname , GetMappedPublicPort ( CosmosDbBuilder . CosmosDbPort ) ) . ToString ( ) ;
48+ }
49+
2850 /// <summary>
2951 /// Gets a configured HTTP message handler that automatically trusts the CosmosDb Emulator's certificate.
3052 /// </summary>
0 commit comments