0

In the older CosmosDB 3.2 I was able to use mongoimport to take data previously backed up by mongoexport and import it into CosmosDB collections. All was well and good.

With the newer CosmosDB 3.6, the same command gets the error:

Retryable writes are not supported. Please disable retryable writes by specifying "retrywrites=false" in the connection string or an equivalent driver specific config

So I do this, I tried &retryWrites=false, &RetryWrites=false, &retrywrites=false in the connection string, but I still get the same error. The same with mongorestore.

I am using the latest mongo-tools v100.2.1.

Anyone got any ideas?

turivishal
  • 34,368
  • 7
  • 36
  • 59
Dan
  • 894
  • 9
  • 21
  • check if it helps **https://stackoverflow.com/questions/63900885/importing-to-cosmosdb-mongodb-api-using-mongorestore-fails-with-retryable-writes** – ROHIT KHURANA Jan 21 '21 at 05:54

2 Answers2

3

I've tried the solution from this answer and it worked indeed.

We can attach this command --writeConcern="{w:0}", here's my result.

mongoimport.exe --uri "<cosmosdb_connect_string>" --db Database1 --collection collection1 --type json --file edx.json --ssl --sslAllowInvalidCertificates --writeConcern {w:0}

enter image description here

Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
0

Enabling Retryable Writes

MongoDB drivers do not enable retryable writes by default.

To enable retryable writes in MongoDB drivers, add the retryWrites option to your connection string:

mongodb://localhost/?retryWrites=true

See documentation

Or do like tiny-wa explained above adding --writeConcern "{w:0}"

Example"

MONGODB_HOST="<your-mongo-db-host-name>"
MONGODB_PORT="10255"
USER="<your-user-name>"

# Copy/past the primary password here
PRIMARY_PW="<your-password>"

DB_NAME="<YOUR DATABASE NAME>"
COLLECTION="<your-collection-name"

mongoimport -h $MONGODB_HOST:$MONGODB_PORT \
-d $DB_NAME -c $COLLECTION -u $USER -p $PRIMARY_PW \
--ssl  --jsonArray  --file sample_collection.json --writeConcern "{w:0}"

See documentation here for Write Concern Documentation

Nayanexx.py
  • 121
  • 1
  • 5