Skip to content

Commit 8394aab

Browse files
feat(CosmosDb): Add get method AccountEndpoint (#1707)
Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
1 parent 08dee67 commit 8394aab

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/Testcontainers.Azurite/AzuriteContainer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ public string GetConnectionString()
3030
}
3131

3232
/// <summary>
33-
/// Gets the blob endpoint
33+
/// Gets the blob endpoint.
3434
/// </summary>
35-
/// <returns>The Azurite blob endpoint</returns>
35+
/// <returns>The Azurite blob endpoint.</returns>
3636
public string GetBlobEndpoint()
3737
{
3838
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.BlobPort), AzuriteBuilder.AccountName).ToString();
3939
}
4040

4141
/// <summary>
42-
/// Gets the queue endpoint
42+
/// Gets the queue endpoint.
4343
/// </summary>
44-
/// <returns>The Azurite queue endpoint</returns>
44+
/// <returns>The Azurite queue endpoint.</returns>
4545
public string GetQueueEndpoint()
4646
{
4747
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.QueuePort), AzuriteBuilder.AccountName).ToString();
4848
}
4949

5050
/// <summary>
51-
/// Gets the table endpoint
51+
/// Gets the table endpoint.
5252
/// </summary>
53-
/// <returns>The Azurite table endpoint</returns>
53+
/// <returns>The Azurite table endpoint.</returns>
5454
public string GetTableEndpoint()
5555
{
5656
return new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(AzuriteBuilder.TablePort), AzuriteBuilder.AccountName).ToString();

src/Testcontainers.CosmosDb/CosmosDbContainer.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)