Azure application settings (for azure function) has a option for a DocumentDB connection string
Anyone have any idea how this should be populated/formatted?
i currently use:
var documentDbEndpointUri = new Uri(ConfigurationManager.AppSettings["DocumentDbEndpointUri"]);
var documentDbAuthKey = ConfigurationManager.AppSettings["DocumentDbAuthKey"];
return new DocumentClient(documentDbEndpointUri, documentDbAuthKey);
Although I'd like to switch to a single value connection string.
Sign in to the AWS Management Console, and open the Amazon DocumentDB console at https://console.aws.amazon.com/docdb . In the left navigation pane, choose Clusters. In the list of clusters, select the name of your cluster.
Connecting using Robo 3TOpen Robo 3T and choose Create. Copy the cluster endpoint from the cluster. On the Connection tab, enter the cluster endpoint information. On the Authentication tab, enter the authentication information for your cluster.
The replica set name cannot be modified. Connecting to the cluster endpoint in replica set mode is the recommended method for general use. All instances in an Amazon DocumentDB cluster listen on the same TCP port for connections.
Try AccountEndpoint=https://accountname.documents.azure.com:443/;AccountKey=accountkey==;Database=database
Firstly, as @Gaurav Mantri said in comment, currently DocumentClient
does not have constructor overloads using connection string, you cannot directly use a connection string to create an instance of DocumentClient even if you provide/add connection string for DocumentDB in Azure application settings.
Note: here is a feedback for this issue, if you have same feature request, you can vote for it.
Secondly, If you’d like to access the DocumentDB service via DocumentClient
, you can add both DocumentDbEndpointUri
and DocumentDbAuthKey
in App settings, and then read them in function code.
var serviceEndpoint = System.Configuration.ConfigurationManager.AppSettings["DocumentDbEndpointUri"];
var authKey = System.Configuration.ConfigurationManager.AppSettings["DocumentDbAuthKey"];
//or
//var serviceEndpoint = Environment.GetEnvironmentVariable("DocumentDbEndpointUri");
//var authKey = Environment.GetEnvironmentVariable("DocumentDbAuthKey");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With