Delete cosmos record with no partition key (Orphan record)

Raghavendra 20 Reputation points
2025-08-14T16:49:17.5666667+00:00

Hi, during development I added a json record to cosmos db through ADF copy activity (source - file, sink - cosmos db) but missed defining the partitionKey inside the json. Now, this record is orphaned. I can query and see that the record exists but I am unable to delete it. I tried options like PartitionKey.None and empty string but fails with error "Message: Entity with the specified id does not exist in the system.". Also tried to set time to live for the container to 5 secs since this is new. The record disappears but when I turn off time to live, it shows up again. How can I get rid of the record?

PS : I tried updating the same record by adding a new entry for partition key but it ended up creating a new record (obvious).

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
{count} votes

Accepted answer
  1. TP 134.2K Reputation points Volunteer Moderator
    2025-08-15T06:29:58.1233333+00:00

    Hi @Raghavendra ,

    I tested using DeleteItemAsync with id and PartitionKey.None and it successfully deleted item that had no partition key. Can you post sample code of how you are attempting to delete the item?

    Instead of using code you could navigate to the Cosmos DB account in Azure portal, click on Data Explorer on left, on right drill down into your Database -- Container -- Items, type filter on top so you only see id you want (e.g. SELECT * FROM c WHERE c.id = "<id you want to delete>") click Apply Filter, select the item, click Delete, confirm.

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.