2
votes

I saw that CosmosDB can be accessed via any supported api regardless of whether it's set up as a GraphDB first. https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-introduction I see the example where I can run a SQL query against the graph database - but how do I get the MongoDB api connection string for it?

Since it was set up as a graphdb api from the start, the mongo db connection strings don't appear in the settings like so: https://docs.microsoft.com/en-us/azure/cosmos-db/connect-mongodb-account#GetCustomConnection

Instead I only see the keys settings.

2

2 Answers

5
votes

So it looks like all I have to do is use the primary key as the password and use the same uri with ssl as the endpoint.

e.g. mongodb://[myInstanceName]:[primaryAccountKey]@[myInstanceName].documents.azure.com:10255/?ssl=true

I left out &replicaSet=globaldb because I was getting errors with that..

1
votes

Currently the APIs in Cosmos DB are not all inter-operable, meaning if you created Gremlin API account, you can't reliably access the data in it with MongoDB API and vice-versa. You can always create separate MongoDB API account in order to be able to read-write data reliably. You will also get the MongoDB connection string right in the portal settings.