您需要拥有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 });
1 回答
您需要拥有SDK 1.6.0或更高版本才能支持Document DB Partitioning . 使用SDK,您需要设置
OfferThroughput
值,如下所示 .在此示例中,我们将
/deviceId
设置为分区键 .注意:
要创建分区集合,必须指定每秒> 10,000个请求单位的
throughput
值 . 由于吞吐量是100的倍数,因此必须为10,100或更高 .因此,当您的
OfferThroughput
设置为小于20000时,您的收藏将是单一分区 .