If go to https://portal.azure.com, open our Azure Cosmos DB account (1) --> Data Explorer (2) --> Click on users (3) --> Click on New SQL Query:
Azure will open a text box to enter a Query:
I've found that Cosmos DB does not allow to use DELETE instead SELECT: https://stackoverflow.com/a/48339202/1198404, so I should do something like:
SELECT * FROM c DELETE c
SELECT * FROM c DELETE *
But any of my attempts worked.
No, you can't delete multiple documents in one go. Each document must be deleted separately. One possible solution would be to write a stored procedure and pass the list of document ids that you want to delete. In that stored procedure, you can loop through that list and delete individual documents.
Access Azure Cosmos DB ExplorerSign in to Azure portal. From All resources, find and navigate to your Azure Cosmos DB account, select Keys, and copy the Primary Connection String. Go to https://cosmos.azure.com/, paste the connection string and select Connect.
Azure Cosmos DB stored procedure is JS script running on the server, you can not debug it on your side. However , you can use console. log () to log some key steps in your stored procedure as below. Then use getScriptLog to get the output from stored procedure console.
A Cosmos DB database can contain zero, one, or more Containers. Containers store items. The hierarchy is described here. I am assuming that you want to clear a Container of all items.
Since your connection string is scoped to the database level, the way I quickly clear a Container of all of its items is to just delete and recreate the Container within the database.
To delete a Container in the Azure Portal, do the following:
For example, if the Container name is users:
One option is to set a TTL of 0 on that particular Container, depending on the number of records though it could take a bit of time.
Alternatively, and this is probably a more viable option, is to simply just to delete & recreate the Container.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With