【发布时间】:2019-01-15 19:27:11
【问题描述】:
我正在尝试在我的 c# 代码中创建一个 azure cosmos 数据库和集合。
await client.CreateDatabaseIfNotExistsAsync(new Database() { Id = "data"});
DocumentCollection dCollection = await client.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri("data"), new DocumentCollection { Id = "coll"}, new RequestOptions { OfferThroughput = 400, , PartitionKey = new PartitionKey("/id") });
// dashboardCollection.PartitionKey.Paths.Add("/id");
当我转到portal.azure.com 并检查我的文档数据库时,该集合已创建。当我去Scale and Settings 收集时,我没有看到分区键。
我手动创建了另一个集合,它在Scale and Settings 部分中显示了分区键。
delete 函数由于此分区键错误而引发错误
已成功将 ID 为 1 的记录插入到文档数据库中。以下删除失败,表明 partitionKey 无效。
ResourceResponse<Document> response = await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri("data", "coll", "1"), new RequestOptions { PartitionKey = new PartitionKey("1") });
【问题讨论】:
标签: c# azure azure-cosmosdb