Loopback connector with Cosmos Mongo DB

Sarah 0 Reputation points
2024-04-07T13:21:35.0133333+00:00

Hi,

I was running an application which uses loopback-connector-mongodb to connect to Mongo DB, but when using the same connector with Cosmos Mongo DB it doesn't work. I tried in the datasources.json using mongodb protocol which gives connection timeout or can't find the server and mongodb+srv protocol which gives querySrv ENOTFOUND _mongodb._tcp.dbname.mongo.cosmos.azure.com.

Please advise if the loopback connector is supported in cosmos mongo db.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,902 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sajeetharan 2,261 Reputation points Microsoft Employee
    2024-04-08T09:18:02.6633333+00:00

    You would need to modify the config in order to make it work with the Mongo API, I have published a sample here.

    here https://github.com/sajeetharan/cosmosdb-loopback4-sample.git

    const Passwordconfig = {
      name: 'db',
      connector: 'mongodb',
      url:
        'mongodb://cosmosbookstorew4zuqbndb3qfq:' + pass + 'restofconnectionstring',
      host: 'cosmosbookstorew4zuqbndb3qfq.mongo.cosmos.azure.com',
      port: 10255,
      useNewUrlParser: true,
      ssl: true,
    };
    
    0 comments No comments

  2. Sajeetharan 2,261 Reputation points Microsoft Employee
    2024-04-08T09:20:28.4633333+00:00

    Hi Sarah,

    You would need to modify the configuration file in order to make it work with the Mongo API, i have published a sample https://github.com/sajeetharan/cosmosdb-loopback4-sample.git

    const Passwordconfig = {
      name: 'db',
      connector: 'mongodb',
      url:
        'mongodb://cosmosbookstorew4zuqbndb3qfq:' + pass + 'restofconnectionstring',
      host: 'cosmosbookstorew4zuqbndb3qfq.mongo.cosmos.azure.com',
      port: 10255,
      useNewUrlParser: true,
      ssl: true,
    };
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.