Returning documents as one file back from Azure CosmosDB

[Reading Time: 2 minutes]

If you ever tried getting multiple documents from CosmosDB collection as on “file”, than you should do the following steps. There can be different requirements for this, but this is not scope of this blog.

Option I – directly in Azure Portal

(Option II – using Datamigration tool)

Here is, what you can do:

    1. First open up “Data Explorer” in CosmosDB Resource (Azure Portal) and select DB->Collection of your interest.
    2. Click “New SQL Query” -> this opens a new query pane with a select statement and also “Setting” to open up the settings SlideIn.

      new query pane
      new query pane
    3. In that SlideIn you have several options.
      – one is to set a custom value on how many results can be displayed in one page
      – another option is to remove the limitation of default 100 to unlimited

      unlimited page results
      unlimited page results
      custom page limit
      custom page limit

       

      ! Don’t forget to save !

    4. Next, go to query pane and leave the select statement, if you have no other conditions on the outcome. Click “Execute Query”. With this you can now grab the output in the results pane by CTRL+A and CTRL+C

      execute query
      execute query
    5. Open your favorit text editor (I like VScode very much), paste in the clipboard and save as a file.

Here you go! 🙂 Hope this helps. If you have other suggestions, you’re welcome to add comments.

By Thomas

As Chief Technology Officer at Xpirit Germany. I am responsible for driving productivity for our customers by a full stack of dev and technology in modern times. But I not only care for technologies from Microsofts stack like Azure, AI, and IoT, but also for delivering quality and expertise with DevOps

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.