How to clear a Cosmos DB database or delete all items using Azure portal
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.
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:
- In the left menu within the portal, choose All resources -> then choose your Cosmos DB resource to bring up the Cosmos DB management blade.
- Choose Data Explorer. You'll see your databases and each Container listed beneath its database.
- Choose the container you want to delete. Once you highlight the menu item for the Container, click the ... to the right of the Container name. This will have a popup menu where you can choose to delete the container.
For example, if the Container name is users: