Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create a collection for mongodb for Azure Cosmos DB Emulator #1552

Open
ihl396 opened this issue Jun 1, 2020 · 21 comments
Open

Cannot create a collection for mongodb for Azure Cosmos DB Emulator #1552

ihl396 opened this issue Jun 1, 2020 · 21 comments
Labels
bug The issue reveals something not working as expected. emulator investigate The issue's root cause is unknown. Someone needs to find that out. mongo

Comments

@ihl396
Copy link

ihl396 commented Jun 1, 2020

Does this occur consistently? Yes
Repro steps:

  1. Startup Azure Cosmos DB emulator with the /EnableMongoDbEndpoint flag
  2. Connect to mongodb endpoint via vscode extension
  3. Create any database
  4. Add Collection, enter a valid partition key
  5. Error appears: Error: Partition key path /id is invalid for MongoDB API.

Action: cosmosDB.createDocDBCollection
Error type: BadRequest
Error Message: Partition key path /id is invalid for MongoDB API.
ActivityId: 735214de-482e-4aaa-897d-b6cf25aac33f, Microsoft.Azure.Documents.Common/2.11.0

Version: 0.13.0
OS: win32
OS Release: 10.0.18363
Product: Visual Studio Code
Product Version: 1.45.1
Language: en

@ejizba ejizba added bug The issue reveals something not working as expected. investigate The issue's root cause is unknown. Someone needs to find that out. labels Jun 11, 2020
@ejizba
Copy link
Contributor

ejizba commented Jun 11, 2020

Need to look into the emulator scenario. I believe partition keys aren't used for mongo and the action says "DocDB" instead of mongo. It could be an issue where we're confusing database types

@ejizba ejizba added this to the 0.15.0 milestone Jun 11, 2020
@houseofyin
Copy link

I ran into this one too.

Anyone have thoughts on how to work around it?

@TheGeekyM
Copy link

Try path "/partition"

@neelip neelip modified the milestones: 0.16.0, 0.17.0 Nov 6, 2020
@hamzahamidi
Copy link

hamzahamidi commented Dec 16, 2020

I run into the same issue. Whenever I enable the endpoint alone using the emulator I can't seem to create a container. This issue is caused by the emulator (very irritating).

https://github.com/MicrosoftDocs/azure-docs/issues/67771

@kosjanne
Copy link

kosjanne commented Mar 1, 2021

Any updates on this? Cosmos DB emulator is basically unusable for MongoDB as collections cannot be created.

@ejizba ejizba modified the milestones: 0.17.0, Backlog Candidates Apr 5, 2021
@hoeghen
Copy link

hoeghen commented Apr 14, 2021

please get this fixed

@niklasden
Copy link

this issue still persists... has anyone found a workaround?

@vs-li
Copy link

vs-li commented Aug 5, 2021

Same here, still running into this issue

@mariomeyrelles
Copy link

We are in September and the issue still persists. Very irritating.

@JameyJohnstonBHP
Copy link

Any updates here? Would really be great if this was fixed!

@erik-metz
Copy link

Same issue here

@IsCaster
Copy link

IsCaster commented Apr 5, 2022

Same here

@otsomkalov
Copy link

This is the critical bug, that doesn't allow to create container and, therefore, work with emulator using mongo endpoint.
And more than 1 year and 10 months it is open, unassigned and still in "Backlog Candidates". Small company Microsoft doesn't have enough resources to fix the problem? You might consider making emulator opensource so people will fix it for you

@tmasselos3
Copy link

Wow. A completely useless emulator for Mongo, although MS markets it as CosmosDB Emulator for Mongo.

@nturinski
Copy link
Member

nturinski commented Apr 28, 2022

Hi everyone,

First off, I'm extremely apologetic for the delay to investigate this issue. There is really no great excuse as why it has been in our backlog for this long when it has been blocking users.

I started investigating this issue, I haven't actually been able to reproduce it.

I am running the current latest version of Azure Cosmos DB Emulator v2.14.6.0 on Windows 11.

Using the cmd terminal with administrator privileges, I started the emulator with the following command:
image

Connecting via Attach Emulator... command on the Databases view and selecting Azure Cosmos DB for MongoDB API. It then connects and I am able to create a database, collection, and read/write documents.

image

Need to look into the emulator scenario. I believe partition keys aren't used for mongo and the action says "DocDB" instead of mongo. It could be an issue where we're confusing database types

As mentioned by @ejizba, partition keys aren't used for MongoDB, so it shouldn't be prompting for a partition key when trying to create a collection. I can't really imagine why it would be doing this, but we do cache the attached accounts, so it's possible that some error occurred with serialization or an update broke compatibility.

If you are seeing DocDB or partition keys, could you try detaching and re-connecting to the emulator and see if that resolves anything?

If anybody could provide some more detailed repro steps, including the version of the emulator, how you are initializing the emulator, and a screenshot of your Attached Database Accounts node (similar to what I provided), that would be immensely helpful.

EDIT: Also, I would like to mention that our team only maintains the Azure Databases VS Code extension. We don't actually do any work on the Azure Cosmos DB Emulator-- we are just trying to enable users to connect to it via VS Code. Unfortunately, if the issue is with the emulator itself, there's not much we can do, but I'll keep investigating this to see if there are any workarounds for our users.

@thepaqman
Copy link

I'm running Ubuntu Desktop 22.04 in Virtual Box (Windows 10 host) and can reproduce this issue. I'm running the emulator with the following docker-compose.yml:

version: "3"
services:
  cosmosdb:
    image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:mongodb"
    ports:
      - "8081:8081"
      - "10251-10254:10251-10254"
    environment:
      - AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10
      - AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true
      - AZURE_COSMOS_EMULATOR_ENABLE_MONGODB_ENDPOINT=4.0
    tty: true
    stdin_open: true

I start the container with docker-compose up -d, navigate to https://localhost:8081/_explorer/index.html

I can create a database no problem, but when I try to add a container I get the issue reported in this thread

image

@jasoncwik
Copy link

@nturinski the issue is with the built-in explorer UI -- it won't let you create a container without specifying the partition key.

For all others, the workaround is to use another tool like mongo shell...

$ ./mongosh "mongodb://localhost:C2y6yDjf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/admin?ssl=true" --tlsAllowInvalidCertificates
Current Mongosh Log ID:	6329518897c01ca257f4e9e7
Connecting to:		mongodb://<credentials>@localhost:10255/admin?ssl=true&directConnection=true&serverSelectionTimeoutMS=2000&tlsAllowInvalidCertificates=true&appName=mongosh+1.5.4
Using MongoDB:		4.0.0
Using Mongosh:		1.5.4

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
globaldb [direct: primary] admin> show dbs
cosmos1  1.00 KiB
globaldb [direct: primary] admin> use cosmos1
switched to db cosmos1
globaldb [direct: primary] cosmos1> db.createCollection('test')
{ ok: 1 }

@kelvien
Copy link

kelvien commented Oct 2, 2022

Make sure that the Docker container is also exposing the 10255 port as well, otherwise accessing it through shell/GUI like Studio 3T will not establish a connection for you

@nturinski
Copy link
Member

Was everyone with this issue using this portal screen to create the collection?

image

While having the partition key as an input is definitely the issue, our extension doesn't control this page. If you are having issues at that page, you'll have to file an issue with the CosmosDB Emulator team. You can find instructions to do that here.

@tshabeer
Copy link

tshabeer commented Nov 13, 2022

Workround for this issue :

1.Start the emulator from command prompt as an administrator with "/EnableMongoDbEndpoint"

  1. Install mongodb compass version 1.28.1 from here https://github.com/mongodb-js/compass/releases/tag/v1.28.1 to connect ,create and manage the database.Use the mongodb connection string from Emulater webpage to connect the database from Mongodb compass.

  2. In the Compass, paste the connectionstring in 'new connection ' view then click the link 'Fill in connection fields indivually'. Go to 'more options ->SSL' then select option 'Unvalidated(insecure)'. Otherwise, connection would fail due to emulator 'self signed' certificate.

  3. Emulater support only wire version 2.0 .So use MongoDB.driver version 2.13.3 from Nuget if .Net

Hope this helps!

@blfuentes
Copy link

Workround for this issue :

1.Start the emulator from command prompt as an administrator with "/EnableMongoDbEndpoint"

  1. Install mongodb compass version 1.28.1 from here https://github.com/mongodb-js/compass/releases/tag/v1.28.1 to connect ,create and manage the database.Use the mongodb connection string from Emulater webpage to connect the database from Mongodb compass.
  2. In the Compass, paste the connectionstring in 'new connection ' view then click the link 'Fill in connection fields indivually'. Go to 'more options ->SSL' then select option 'Unvalidated(insecure)'. Otherwise, connection would fail due to emulator 'self signed' certificate.
  3. Emulater support only wire version 2.0 .So use MongoDB.driver version 2.13.3 from Nuget if .Net

Hope this helps!

Thanks for the workaround, but it didn't work for me. I still get the self signed issue, any ideas?

I updated to latest compass 1.43.x and still not working

@sevoku sevoku added the mongo label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue reveals something not working as expected. emulator investigate The issue's root cause is unknown. Someone needs to find that out. mongo
Projects
None yet
Development

No branches or pull requests