user2647050
user2647050

Reputation: 1

I am not able to delete document from azure Cosmos DB database

I am learning micorosoft azure and facing this issue. My Document is :

{
    "customerid": 1,
    "customername": "Ron",
    "city": "NewYork",
    "id": "0c288834-fc7d-4f9d-95c7-722596e275c8"
}

My Code is:

CosmosClient cosmosClient = new CosmosClient(endPoint, accountKey);
Database database = cosmosClient.GetDatabase(databaseName);
Container container = database.GetContainer(conatinerName);
PartitionKey pk = new PartitionKey("NewYork");
string id = "0c288834-fc7d-4f9d-95c7-722596e275c8";
ItemResponse<customer> t =container.DeleteItemAsync<customer>(id, pk).Result;

Every time i get the same error: One or more errors occurred. (Response status code does not indicate success: NotFound (404); Substatus: 0; ActivityId: f40e6c70-589a-43d3-a329-aa4564fcc630; Reason: ({ "Errors": [ "Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"]});)

The error is not clear.Please help me to find the solution

Upvotes: 0

Views: 1527

Answers (1)

Steve Johnson
Steve Johnson

Reputation: 8690

Your code is right.I delete it successfully on my side.Please check whether your conatinerName is same with yours on azure portal.Other things like id,partition key value can also cause this error,please make sure they are right.(They are correct in your code,if document you provide is right)

Upvotes: 1

Related Questions