Skip to content

[Enhancement]: CosmosDb: Add getters for AccountEndpoint and AccountKey #1704

Description

@srollinet

Problem

In my test setup, I need to get the ComsmosDb container's AccountEndpoint and AccountKey properties to configure my services.

CosmosDbContainer exposes the connection string that contains these properties. But it would be more convenient to have those properties directly exposed rather than having to parse the connection string

public string GetConnectionString()
{
var properties = new Dictionary<string, string>();
properties.Add("AccountEndpoint", new UriBuilder(Uri.UriSchemeHttp, Hostname, GetMappedPublicPort(CosmosDbBuilder.CosmosDbPort)).ToString());
properties.Add("AccountKey", CosmosDbBuilder.DefaultAccountKey);
return string.Join(";", properties.Select(property => string.Join("=", property.Key, property.Value)));
}

Solution

Add getters or get methods to return both AccountEndpoint and AccountKey and rewrite GetConnectionString to use those getters.

Benefit

Getting the properties in a more convenient way, while keeping the CosmosDbContainer class easy to read and maintain.

Alternatives

Get them by parsing the connection string as done today.

Would you like to help contributing this enhancement?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions