Delete Multiple DocDb Documents within the Azure Portal RRS feed

  • Question

  • Hi, 

    I'm looking for a way to delete multiple DocDB documents without using the 'document explorer' or any external APIs etc. 

    I've had a good look through the Azure Portal, and I can't seem to find a place that lets me do a 'DELETE * FROM c WHERE'...

    The query explorer doesn't allow this, so I've drawn a complete blank. We are using our DocDB as a buffer for another DB so need to clear old documents soon, as we are close to our quota. 

    Wednesday, February 8, 2017 4:26 PM

All replies

  • Hi,

    You can execute this script using Script Explorer in the portal: https://github.com/Azure/azure-documentdb-js-server/blob/master/samples/stored-procedures/bulkDelete.js.


    Wednesday, February 8, 2017 7:20 PM
  • when i run above stored procedure on portal it is asking for partition key, I want to delete documents where it does not contain any partition keys. I have documents with both parition key and without parition key, please help me if the doucments does not contain partition key how to delete them
    Monday, January 14, 2019 1:24 AM
  • Piece of crap didn't work. Kudos!
    Saturday, August 3, 2019 7:47 PM
  • Execute Stored Procedure then Enter your partition key. And then Click on "Add New Param" and then use "
    Tuesday, August 6, 2019 2:47 PM
  • Tried that bulkDelete today as well, even with the example select, the one mentioned by you and even a simple "SELECT * FROM c" does not work. It just says 0 documents deleted and no continuation.

    No documents are deleted in the process either.

    Thursday, August 22, 2019 11:47 AM
  • Hi 

    The whole process works on Partition key value rather than the partition key while executing this stored procedure.

    Lets take an example. Here we have a cosmos DB with zipcode as the partition key.

    If we have to delete the 2 items with zipcode 22 we will create the stored procedure with code given in :


    When you will execute the SP, where you have select the partition key, you will select the value of 22 rather than /zipcode or anything else. and you will use the following parameter value.

    SELECT * FROM c WHERE c.zipcode= "22" 

    Here is the screen shot:

    The result for the same will display 2 items have been deleted and the item will also show the two items with zipcode 22 is deleted.

    So this SP will work with choosing the appropriate Partition Key. Hope this has helped. Please get back to us if any question.

    Navtej S

    Friday, August 23, 2019 10:03 PM