can't delete items by using the Data Explorer of Azure CosmosDB?

jane 60 Reputation points
2023-12-14T05:53:47.2933333+00:00

I tried to directly delete all items under a certain partitionKey using SQL Query in the Data Explorer, but it consistently shows an error.

How can I achieve deletion within the Data Explorer instead of using the SDK?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,924 questions
{count} votes

Accepted answer
  1. Sajeetharan 2,261 Reputation points Microsoft Employee
    2023-12-14T09:41:13.45+00:00

    You are using wrong command , the Cosmos DB NOSQL API's is specifically for querying. That is, it only provides SELECT, not UPDATE or DELETE.

    You need to use any of the SDK or REST endpoint to do the delete operation. Or you can set TTL on the item to remove the document.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2023-12-14T06:48:09.2233333+00:00

    Hi
    jane
    ,

    Welcome to Microsoft Q&A forum.

    As I understand, you want to know if you can delete items by using the Data Explorer of Azure CosmosDB.

    Here is the documentation for the same, please take a look and let us know if you follow it:

    https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/how-to-delete-by-partition-key?tabs=dotnet-example

    Please share what error comes up when you perform deletion.

    Please note that Hierarchical partition keys deletion is not supported. This feature permits the deletion of items solely based on the last level of partition keys. For example, consider a scenario where a partition key consists of three hierarchical levels: country, state, and city. In this context, the delete by partition keys functionality can be employed effectively by specifying the complete partition key, encompassing all levels, namely country/state/city. Attempting to delete using intermediate partition keys, such as country/state or solely country, will result in an error.

    Let us know if further queries.

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.