Exporting data from Azure DocumentDB
Asked Answered
T

4

18

is there an option in Azure to export an existing collection from DocumentDB?

I could only seen an Import option.

Tericaterina answered 9/6, 2015 at 9:27 Comment(1)
Not sure if it the same, but we have been able to export the database into json by using the export tool of this answer: #64050707Neidaneidhardt
A
19

There is no built-in export option in the database service itself. However, the DocumentDB Data Migration Tool, published by the DocumentDB team, is available and provides both import and export capabilities (export is to JSON). Everything is documented on the DocumentDB area of the Azure site, specifically here.

This isn't your only option, as you can write your own export app based on one of the existing language SDKs or direct REST API calls.

There may be other tools available, but getting into a which is the best tool for this discussion is off-topic. I'm only pointing out the Data Migration tool because the DocumentDB team provides it, along with official documentation.

Accomplish answered 9/6, 2015 at 13:19 Comment(3)
In addition to David's suggestion you can also use Azure Data Factory data movement activities to move data from DocumentDB to a number of destinations, including Blob storage and even another DocumentDB account. For more info on this check out azure.microsoft.com/en-us/documentation/articles/…Plater
How in the world it is accepted solution when it's says "no way" and my solution directly points to official Microsoft tool to do it ?Anecdote
Does migration tool allow exporting data from cosmos db to csv format?Brandiebrandise
A
16

Surprisingly, as of ~mid-2017 there still not does not appear to be a simple "Download DB" and "Upload DB" type functionality for Azure CosmosDB (previously known as DocumentDB). Here is one option:

Caveat: Below method does not appear to support exporting attachments. If that is something you need, this might not work for you.

Export locally to a JSON file

Use the Azure DocumentDB Data Migration Tool to export and import DocumentDB collections.

In Source Information Page:

  1. Select DocumentDB as source
  2. In connection string, provide the connection string from the Azure Portal.
  • Format is: AccountEndpoint=http://blah.documentdb.com/;AccountKey=blahblah;Database=dbname To export, select "JSON file" as target and your documentDB as source
  1. Ensure Database valid exists in connection string, if not, append it.
  • Click Verify to ensure your connection works.
  1. Enter a valid collection name in the collection field.

sourceinformationpage


In **Target Information** Page:
  1. Export to JSON.
  2. Chose Local File and enter a valid path.
  3. (optional) Check Prettify JSON

targetinformationpage

Tested: 2017-06-16 against an Azure CosmosDB instance

Adrastus answered 12/12, 2017 at 22:18 Comment(0)
A
8

Use the Azure DocumentDB Data Migration Tool to export and import DocumentDB collections.

To export, select "JSON file" as target and your documentDB as source

UPDATE : new (better) version is avalible here : https://github.com/Azure/azure-documentdb-datamigrationtool

Anecdote answered 28/11, 2015 at 21:22 Comment(6)
This is nonsense. I propose a solution to the problem and I get downvoted. While accepted solution does not even answer the question…Anecdote
interesting, have this been updated since your last comment? are there any restrictions still in place when migrating Document DB collections? thanksDisastrous
@HoriaToma It was updated. The tool is much better now. BUT : I needed to migrate about 1GB of data to new CosmosDB collection. The precompiled tool didn’t work (crush at first data entry), but getting source code, lunching in Debug mode worked just fineAnecdote
@HoriaToma Updated response with new linkAnecdote
2022 and this worked perfectly for me. If you're pulling the conn string from Azure Portal, don't forget to append 'Database=XXXXXX'.Picco
Now retired - New tool at github.com/AzureCosmosDB/data-migration-desktop-toolBecky
G
0

Use MongoExport if you've enabled the Mongo interface in Cosmos: https://www.mongodb.com/docs/database-tools/mongoexport/.

Gerge answered 1/2, 2023 at 17:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.