Skip to content

CosmosDB ARM library makes it hard to pick which connection string to use #19935

Open

Description

Package: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos
Version: v1.0.0

In the armcosmos package, the DatabaseAccountsClient.ListConnectionStrings() returns a model that looks like this:

type DatabaseAccountListConnectionStringsResult struct {
  ConnectionStrings []*DatabaseAccountConnectionString `json:"connectionStrings,omitempty"`
}

type DatabaseAccountConnectionString struct {
	// READ-ONLY; Value of the connection string
	ConnectionString *string `json:"connectionString,omitempty" azure:"ro"`

	// READ-ONLY; Description of the connection string
	Description *string `json:"description,omitempty" azure:"ro"`
}

The 'Description' field appears to be a human readable string (ex: Primary SQL Connection String), which makes it difficult to programmatically pick the right one, or at least potentially fragile if the description were to change.

There's a similar API to that retrieves keys, instead of connection strings. That API has fields for each type of key, making it much easier:

type DatabaseAccountListKeysResult struct {
	PrimaryMasterKey *string `json:"primaryMasterKey,omitempty" azure:"ro"`
	PrimaryReadonlyMasterKey *string `json:"primaryReadonlyMasterKey,omitempty" azure:"ro"`
	SecondaryMasterKey *string `json:"secondaryMasterKey,omitempty" azure:"ro"`
	SecondaryReadonlyMasterKey *string `json:"secondaryReadonlyMasterKey,omitempty" azure:"ro"`
}

Is there a reason the connection string API is not built like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

CosmosMgmtThis issue is related to a management-plane library.Service AttentionWorkflow: This issue is responsible by Azure service team.design-discussionAn area of design currently under discussion and open to team and community feedback.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions