Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocumentDB connection string

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.

like image 263
John Avatar asked Jul 29 '17 06:07

John


People also ask

How do I access Amazon DocumentDB?

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.

How do I connect to robo 3T DocumentDB?

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.

Which port does a DocumentDB cluster listen on?

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.


2 Answers

Try AccountEndpoint=https://accountname.documents.azure.com:443/‌​;AccountKey=accountk‌​ey==;Database=database

like image 57
hsedidin Avatar answered Nov 08 '22 07:11

hsedidin


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.

enter image description here

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");
like image 34
Fei Han Avatar answered Nov 08 '22 07:11

Fei Han