Skip to content

Cosmos: Support creating a client from a connection string #1939

@analogrelay

Description

@analogrelay

We support two ways to create a CosmosClient:

  • CosmosClient::new(endpoint: &str, credential: Arc<dyn TokenCredential>, options: Option<CosmosClientOptions>) which uses Entra ID
  • CosmosClient::with_key(endpoint: &str, key: azure_core::Secret, options: Option<CosmosClientOptions>) which uses key-based auth (Requires key_auth feature)

We don't support specifying a connection string, since with_key accepts all the values a connection string would normally provide. However, often users specify connection strings in config, and our other clients can be constructed from a connection string. So, we should add another method:

  • CosmosClient::with_connection_string(connection_string: azure_core::Secret, options: Option<CosmosClientOptions>)

This method would require the key_auth feature, since it's for specifying a key. Also, the connection string should be a Secret because it contains the key.

Metadata

Metadata

Labels

CosmosThe azure_cosmos crate

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions