3

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?

BradleyDotNET
  • 60,462
  • 10
  • 96
  • 117
  • Can you please edit your question and add clarification about where you're seeing the connection string in Azure? And also add clarification if you provisioned your MongoLab database via MongoLab.com or through the add-ons within the Azure portal? – David Makogon Jun 12 '14 at 04:15
  • I edited. I'm wondering that maybe the Azure connection string has my Azure credentials encoded or something like that. – Jose Daniel Chacón Bogarín Jun 12 '14 at 15:49
  • 1
    Um... if I were you, I'd edit again and remove the actual details of that connection string (you need to obfuscate it). And when you say main management site: Did you actually create this as an add-on through the portal? – David Makogon Jun 12 '14 at 17:06

2 Answers2

5

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 support@mongolab.com directly if you have any questions!

Sincerely,

Eric@MongoLab

Eric
  • 450
  • 2
  • 6
0

You should go with the one provided when you go to the details of your database on the MongoLab site. It should look like this

mongodb://<dbuser>:<dbpassword>@ds048537.mongolab.com:48537/<databasename>

I don't know what kind of connection string Azure is showing you, but the format above works pretty well on Azure.

Horizon_Net
  • 5,959
  • 4
  • 31
  • 34