【发布时间】:2020-09-03 23:32:26
【问题描述】:
我正在学习 micorosoft azure 并面临这个问题。 我的文件是:
{
"customerid": 1,
"customername": "Ron",
"city": "NewYork",
"id": "0c288834-fc7d-4f9d-95c7-722596e275c8"
}
我的代码是:
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;
每次我得到同样的错误: 发生一个或多个错误。 (响应状态码不表示成功:NotFound(404);Substatus:0;ActivityId:f40e6c70-589a-43d3-a329-aa4564fcc630;原因:({ “错误”:[“找不到资源。了解更多:https://aka.ms/cosmosdb-tsg-not-found”]});)
错误不清楚。请帮我找到解决办法
【问题讨论】:
-
错误很明显:在该分区键下找不到特定的 ID。尝试仅使用 ID 删除而不使用分区键。
-
你的分区键是什么?好像不是“/city”。
-
我的分区键是“城市”
标签: c# azure azure-cosmosdb azure-cosmosdb-sqlapi