Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which MongoLab connection string should I use?

I'm going to deploy a website to Azure using MongoLab, but I got into a bit of confusion.

When I log to MongoLab site I get one Uri, but in the Azure site, if I hit connection string I get a different one. The Azure one is quite long and there is no space for putting user and password.

I get the Azure connection string when I select it in the main management site and hit the Connection Info button below. The other one I see it in the MongoLab site.

Also, I made the MongoLab DB from within the Azure Portal.

The connection string I see in Azure is this

mongodb://AzureAppServiceName:M.qKtufxLrRxv.1SwDBKelfkchdjCe08Cmv79lvTD2I-@ds035747.mongolab.com:port/DBName

And the one in MongoLab site is this:

mongodb://<dbuser>:<dbpassword>@ds035747.mongolab.com:port/DBName

Which one should I use?

I'm wondering that one is for direct connection to MongoLab when there is no restriction of ports whatsoever, such as development, and the other one is to connect when the site is deployed because of internal network restrictions in the Azure infrastructure.

Is this understanding correct?

like image 322
Jose Daniel Chacón Bogarín Avatar asked Feb 23 '26 13:02

Jose Daniel Chacón Bogarín


1 Answers

The connection string provided in the MongoLab UI is a template that can be used when constructing your own URI when you create database users of your own.

When you provision a MongoLab database using the MongoLab addon in the Azure store, MongoLab passes the connection URI we generate to Azure. This pre-generated URI is the one available in the "Connection Info" section of the addon screen.

You can immediately use that URI in the connection info screen as suggested in the Quick Start provided at the top of this article: http://azure.microsoft.com/en-us/documentation/articles/store-mongolab-web-sites-dotnet-store-data-mongodb/. The quick start provides the steps for transferring the addon connection info to the environment variables of an Azure website.

It is also, as other responses suggest, entirely plausible to use that URI elsewhere or to create your own username and password after SSOing to MongoLab (using the URI template at the top of the page to construct a URI of your own).

Don't hesitate to email us at [email protected] directly if you have any questions!

Sincerely,

Eric@MongoLab

like image 127
Eric Avatar answered Feb 26 '26 03:02

Eric