microsoft / vscode-cosmosdb

Azure Databases extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb
MIT License
156 stars 67 forks source link

VSCode with MongoDB Atlas #724

Closed msamyelsheikh closed 3 years ago

msamyelsheikh commented 6 years ago

Repro steps: Did anyone succeed in connecting to MongoDB Atlas from VSCode? It gives me this error although it does connect with MongoDB Compass

Action: cosmosDB.attachDatabaseAccount Error type: Error Error Message: failed to connect to server [xxx.mongodb.net:27017] on first connect [MongoError: getaddrinfo ENOTFOUND xxx.mongodb.net xxx.mongodb.net:27017]

Version: 0.6.0 OS: darwin

MullinsN commented 5 years ago

I have tried to connect to the MongoDB atlas databases, and have failed twice.

When the connection strings are used normally, at the command prompt, then a shell is fired up which correctly connects to the atlas databases.

So below is an example of the connection string I am using.

mongodb://cluster0-shard-00-00-xxxxxx:27017,cluster0-shard-00-01-xxxxxx:27017,cluster0-shard-00-02-xxxxxxx::27017/aggregations?replicaSet=Cluster0-shard-0 --authenticationDatabase xxxx --ssl -u xxxxx -p xxxxxxx --norc

So I tried mongodb+srv, since there are multiple hostnames, and the issue is that the extension does not support this at the moment.

PrashanthCorp commented 5 years ago

It looks like I'm able to connect to an atlas account. These are the specifics of the account: Free Tier, user is admin, account hosted on Azure (via Atlas). Here's what the connection string looks like:

mongodb://<USERNAME>:<PASSWORD>@cluster0-shard-00-00-<Atlas_Endpoint>.azure.mongodb.net:27017,cluster0-shard-00-01-<Atlas_Endpoint>.azure.mongodb.net:27017,cluster0-shard-00-02-<Atlas_Endpoint>.azure.mongodb.net:27017/<DB_Name>?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true
MullinsN commented 5 years ago

Why is it necessary to add the azure section if I would like to connect directly to MongoDB Atlas? Does this mean an Azure account is necessary, or that the routing of the MongoDB connection request is via Azure.

I must assume that I am missing a salient point in how the comosDB extension is working?

EDIT - Connected directly to MongoDB Atlas, without the Azure part in the example you provided, so thanks for that guidance.

Dropping the / from command also allowed the connection to see all the databases in that cluster, thereby allowing a connect to the database of choice, from within VSC.

PrashanthCorp commented 5 years ago

The azure.mongodb.net came about only because of I chose Azure as the cloud provider to host the Atlas instance on. I had a choice between GCP, AWS, Azure. Did you run Mongo Atlas on any of these clouds?

MullinsN commented 5 years ago

Ahhhh.

So my free cluster is hosted via AWS, once I looked into how I originally confiigured the cluster on

https://cloud.mongodb.com

I have to be honest it is a big bonus to get intellisense on both collection names and operators for MongoDB via VSC. MongoDB can be quite unforgiving on typos, including mismatched brackets.

Probably outside the remit of the extension, but schema analyzer, like MongoDBs compass would be a bonus ;)

vbhv10 commented 4 years ago

Ahhhh.

So my free cluster is hosted via AWS, once I looked into how I originally confiigured the cluster on

https://cloud.mongodb.com

I have to be honest it is a big bonus to get intellisense on both collection names and operators for MongoDB via VSC. MongoDB can be quite unforgiving on typos, including mismatched brackets.

Probably outside the remit of the extension, but schema analyzer, like MongoDBs compass would be a bonus ;)

Hey bro ...how did you connect your cluster hosted via AWS in vs code

msamyelsheikh commented 4 years ago

Why is it necessary to add the azure section if I would like to connect directly to MongoDB Atlas? Does this mean an Azure account is necessary, or that the routing of the MongoDB connection request is via Azure.

I must assume that I am missing a salient point in how the comosDB extension is working?

EDIT - Connected directly to MongoDB Atlas, without the Azure part in the example you provided, so thanks for that guidance.

Dropping the / from command also allowed the connection to see all the databases in that cluster, thereby allowing a connect to the database of choice, from within VSC.

We are not adding Azure section, I am asking about using VS IDE to connect to MongoDB on Atlas

MullinsN commented 4 years ago

Hello,

So I took the example PrasthanCorp provided and worked from that.

Ok, so if you go onto your atlas cluster and get the connection string, which follows the format below, then swap the for the endpoints for your cluster.

Then drop the /, so you can see all the databases in your cluster. This way you avoid having to define the database you want to connect to.

mongodb://USERNAME>:<PASSWORD>@cluster0-shard-00-00-<Atlas_Endpoint.azure.mongodb.net:27017,cluster0-shard-00-01-.azure.mongodb.net:27017,cluster0-shard-00-02-.azure.mongodb.net:27017/?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

It's been 10 months since I did this, so not massively fresh.

AzCode-Bot commented 3 years ago

This issue has become stale and is at risk of being closed. The community has 60 days to upvote the issue. If it receives 5 upvotes we will keep it open and take another look. If not, we will close it. To learn more about how we handle issues, please see our documentation.

Happy Coding!

AzCode-Bot commented 3 years ago

:slightly_frowning_face: In the last 60 days, this issue has received less than 5 community upvotes and we closed it. Still a big Thank You to you for taking the time to create it! To learn more about how we handle issues, please see our documentation.

Happy Coding!