1
votes

I installed the Azure CosmosDB Emulator on my Win10 computer, and I have the visibility of the launching page :

enter image description here

But when I try to connect to the database throught Robo3T or command line it doesn't work. I use the following cmd :

mongo mongodb://localhost:foofoojf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/admin?ssl=true

And I got the following issue :

2019-07-18T14:33:27.265+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:10255 after 5000ms milliseconds, giving up. 2019-07-18T14:33:27.266+0200 E QUERY [thread1] Error: couldn't connect to server localhost:10255, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed

It is locally so I assume there is no port issue. Is it possible to be something related to the local certificat or my compagnie firewall ?

2

2 Answers

1
votes

I connected mongo emulator with ROBO3T tool, please see my configuration.

Firstly, get the emulator connection string from this link.

mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true

Then create the connect configuration:

Connection:

enter image description here

Authentication:

enter image description here

SSL:

enter image description here

Click Test button:

enter image description here

UI:

enter image description here

0
votes

In my case, to interact Azure CosmosDb API for MongoDb we need to create a dedicated new folder under %localappdata%\CosmosDbEmulator and enable MongoDb endpoint v3.6 (see below PowerShell command in Step 1).

Note: For any reason if CosmosDb emulator is reset to default folder path %localappdata%\CosmosDbEmulator (or) fail to connect in Robo 3T then always execute the below PowerShell script in Step 1 once again.

Note: From Robo 3T v1.4 onwards we don't have SSL tab in connection Settings dialog. Instead we have a tab TLS.

1. Download and install Azure CosmosDb Emulator from https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=powershell%2Cssl-netstd21
2. Download and install Robo 3T (1.4.2 or latest) from https://robomongo.org/download
3. To show Azure CosmosDb emulator related database(s) in Robo 3T client app

Step 1
- Launch Azure CosmosDb Emulator 
  (Optional: Just to check CosmosDbEmulator is started successfully)
- Open Powershell as administrator and execute below commands
  # PowerShell Script
  # Change directory to default location where CosmosDb emulator is installed.
  cd\
  cd '.\Program Files\Azure Cosmos DB Emulator\'
             
  # [Optional] If any cosmosDb emulator instance is running then shutdown
  .\Microsoft.Azure.Cosmos.Emulator.exe /shutdown
        
  # To interact Azure CosmosDb API for MongoDb, create a new folder "<MongoDb>" under 
  # %localappdata%\CosmosDbEmulator and enable MongoDb endpoint v3.6
  .\Microsoft.Azure.Cosmos.Emulator.exe /DataPath="$env:localappdata\CosmosDBEmulator\MongoDb" /EnableMongoDbEndpoint=3.6
Step 2      
- Now CosmosDb emulator will be successfully started,
  and launches the URL https://localhost:8081/_explorer/index.html in the browser
- Note down MongoDb connection string details from browser which will be required 
  while creating new Robo 3T connection. The default MongoDb connection string format is 
  mongodb://username:password@host:port/[database]?ssl=true
    - Username: localhost
    - Password (Primary Key): C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
    - Port: 10255
    - Database: admin
    
Step 3
- Launch Robo 3T
- Click on Create new connection 
- In "Connection" tab
    - Provide Name of the connection as "<CosmosDbEmulator>"
    - Add port number as 10255
        
- In "Authentication" tab provide details noted down in previous Step 2
    - Check "Perform authentication"
    - Add Database as "admin"
    - Add Username as "https://localhost:8081"
    - Add Password as "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
        
- In "TLS" tab provide
    - Check "Use TLS protocol"
    - From Authentication Method dropdown select "Self-signed Certificate"
        
- Click on "Test" button. 
    - It should successfully connects to localhost:10255 via TLS tunnel
    - It should successfully authorise to database "admin"
    
- Click on "Save" button    
- Click on "Connect" button. 
    - It will show the admin database and its related collections.