Azure Cosmos DB: Clone collection to another database
Solution 1
You can use data Migration tool
suggested by Microsoft to do the same.
There is no way to take a backup and import cosmosdb.
EDIT:
With the new Cosmic Clone
tool, you can take a clone/backup with data/stored procedures/triggers/udf, etc. Read my blog
on the same.
Solution 2
I already tried to use Azure Data factory, but it looks like that there is no support for the Mongo API so far.
Actually, Cosmos DB Mongo API and SQL API are all belong to Azure Cosmos DB service.So , you still can create cosmos db linked service and dataset in the azure data factory for your database.
Then you could create copy activity to import data from one collection to another collection.
If you want to make it as an automation task, I suggest using following 2 ways to run the copy activity.
1.Azure Time Trigger Function.
2.Web job which is run in the background of Azure Web App.
Hope it helps you.Any concern, please feel free to let me know.
Related videos on Youtube
Fabian
Updated on June 04, 2022Comments
-
Fabian almost 2 years
Currently I am trying to clone a cosmos db collection from one database to another database within the cosmos db. The API of the cosmos db is set to Mongo API.
I already tried to use Azure Data factory, but it looks like that there is no support for the Mongo API so far.
Has anyone an idea how to do this respective to efficiency, automation and performance?
Any ideas are appreciated.
-
Fabian almost 6 yearsI forgot to mention that I need this on a daily basis as an automation task.The software don't seem to be able to be used in an automation environment.
-
Sajeetharan almost 6 yearsin that case you need to write a function or web job to do that using api
-
Fabian almost 6 yearsthat is what I already does, but it seems, that the migration process corrupts my collection. The job finished without error, but from the Azure Portal, as well as with Robo 3T no access to the collection is possible anymore ...
-
Fabian almost 6 yearsI guess so ... Hope that something is coming up, which can be used out of the box :)
-
Fabian almost 6 yearsHi Sajeetharan, I looked up your idea with the Migration tool. This will not work in this setup, as the documentation says: "The Data Migration tool does not currently support Azure Cosmos DB MongoDB API either as a source or as a target."
-
Udhaya about 5 yearsuse 'skip incompatible rows and log' errors..on fault tolerance.
-
Sajeetharan about 5 years@Fabian now you can do backup with cosmosdb check the updated answer
-
Sajeetharan about 5 years
-
Venky almost 5 years@Sajeetharan does
Cosmic Clone
work for cloning gremlin collection ? -
Benjamin Brandt about 3 yearsNote: Latest commit of Cosmic_Clone adds this to the README:
**Disclaimer**: Please note this is not an official tool from the Azure Cosmos DB team, but a utility developed by an independent developer within Microsoft IT and offered on Github as a sample.
Any ideas if a production-ready tool is in the works to replace it?