[英]Create Collection in Azure DocumentDB with Different Partition Mode
有一些示例代码使用Microsoft.Azure.DocumentDB在azure documentDB中创建集合。 但是,我找不到有关如何使用c#创建具有不同分区模式的集合的信息。
从门户网站,有两种模式:单一分区和分区。
使用Microsoft.Azure.DocumentDB创建集合时,我们可以使用其中一个吗?
您需要拥有SDK 1.6.0或更高版本才能支持Document DB Partitioning。 使用SDK,您需要设置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 });
注意:
要创建分区集合,必须指定throughput
值> 10,000每秒请求单位。 由于吞吐量是100的倍数,因此必须为10,100或更高。
因此,当您的OfferThroughput
设置为小于20000时,您的集合将是单一分区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.