url*_*der 3 c# azure azure-cosmosdb
有一些示例代码使用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 });
Run Code Online (Sandbox Code Playgroud)
注意:
要创建分区集合,必须指定throughput
每秒> 10,000个请求单位的值.由于吞吐量是100的倍数,因此必须为10,100或更高.
因此,当您OfferThroughput的设置小于20000时,您的收藏将是单一分区.
| 归档时间: |
|
| 查看次数: |
3343 次 |
| 最近记录: |