bmvr
bmvr

Reputation: 866

Azure DocumentDB | Connection Strings missing on Settings

I've noticed that connection strings link is missing on settings section in Azure Portal.

I was following this tutorial in order to use .NET mongodb driver to work with Azure DocumentDB.

Look at the image below(from the tutorial) enter image description here

And in my azure portal it does not show the connection strings.

enter image description here

Upvotes: 1

Views: 1281

Answers (2)

David Makogon
David Makogon

Reputation: 71025

The Connection Strings option appears when you configure a database with MongoDB compatibility (which you must choose when creating your new database:

mongo compat enable

Once you do this, you'll then have the Connection String option:

mongo connection string

With databases where you have not enabled MongoDB compatibility, you're correct that the connection info appears under Keys:

DocumentDB keys

Upvotes: 4

bmvr
bmvr

Reputation: 866

I've managed to build my connection string by comparing the tutorial screen shots and the information that is on my Azure Portal. I've navigate to Keys link, and used the Primary Key as Password but that's not very obvious since the word may confuse the reader.

Also the Port 10250 that is shown in the tutorial is not mentioned anywhere in the Azure Portal, I've just tried it and it worked.

It makes me believe that connection strings link is missing on purpose and not due a bug.

For those who are looking for the Connection Strings link to complete the tutorial here's what I did.

string endpoint = "bi4all-nosql"; //Your DocumentDB Name
string password ="********"; //Primary Key
string ConnectionString = $"mongodb://{endpoint}:{password}@{endpoint}.documents.azure.com:10250/?ssl=true";

MongoClientSettings settings = MongoClientSettings.FromUrl(new MongoUrl(ConnectionString));
settings.SslSettings = new SslSettings
            {
                EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12
            };
MongoClient client = new MongoClient(settings);

Upvotes: 0

Related Questions