有一些示例代码可以使用Microsoft.Azure.DocumentDB在Azure DocumentDB中创建集合。然而,我找不到关于如何使用c#创建具有不同分区模式的集合的信息。
从门户中,有两种模式:单个分区和分区。
我们可以在使用Microsoft.Azure.DocumentDB创建集合时使用其中一种吗?
有一些示例代码可以使用Microsoft.Azure.DocumentDB在Azure DocumentDB中创建集合。然而,我找不到关于如何使用c#创建具有不同分区模式的集合的信息。
从门户中,有两种模式:单个分区和分区。
我们可以在使用Microsoft.Azure.DocumentDB创建集合时使用其中一种吗?
OfferThroughput
值。在这个示例中,我们将/deviceId
设置为分区键。DocumentClient client = new DocumentClient(new Uri(endpoint), authKey);
await client.CreateDatabaseAsync(new Database { Id = "db" });
// Collection for device telemetry. Here the JSON property deviceId will be used as the partition key to
// spread across partitions. Configured for 10K RU/s throughput and an indexing policy that supports
// sorting against any number or string property.
DocumentCollection myCollection = new DocumentCollection();
myCollection.Id = "coll";
myCollection.PartitionKey.Paths.Add("/deviceId");
await client.CreateDocumentCollectionAsync(
UriFactory.CreateDatabaseUri("db"),
myCollection,
new RequestOptions { OfferThroughput = 20000 });