0
votes

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

1
Error is pretty clear: it can't find a specific ID under that partition key. Try just deleting using just the ID and no partition key.Andy
What is your Partition key?It seems not "/city".Steve Zhao
My Partition key is "city"user2647050

1 Answers

1
votes

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)