-
-
Notifications
You must be signed in to change notification settings - Fork 343
Description
Problem
Right now, CosmosDbContainer has a string GetConnectionString() method which returns a connection string for use on the host. It would be useful if CosmosDbContainer also had a method returning a connection string usable within a network the container is attached to. Ideally, this method would work before the container is started so that it can be used to build other containers which rely on this connection string.
Solution
I propose adding a method to class CosmosDbContainer which is functionally equivalent to:
private string GetInternalConnectionString(string networkAlias)
{
var properties = new Dictionary<string, string>
{
["AccountEndpoint"] = new UriBuilder(Uri.UriSchemeHttps, networkAlias, CosmosDbBuilder.CosmosDbPort).ToString(),
["AccountKey"] = CosmosDbBuilder.DefaultAccountKey
};
return string.Join(";", properties.Select(kvp => string.Join("=", kvp.Key, kvp.Value)));
}Benefit
This method will make it easier to create connection strings used to build other containers which communicate with the cosmos container.
Alternatives
This connection string can be created using the code snippet proposed above, but results in duplicated code.
Would you like to help contributing this enhancement?
Yes