使用不同的分区模式在Azure DocumentDB中创建集合
有一些示例代码使用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时,您的集合将是单一分区。
- 请求在Azure AppService中排队,尽管它在线程池中有足够的线程
- Azure中的C#DateTime.Now未报告GMT – 是否可以设置默认时区?
- Azurefunction的事件中心输入绑定
- 如何在没有登录的情况下使用window azure media server的文件路径阻止播放video?
- 如何更改服务总线队列的属性?
- 如何在Azure应用程序洞察中忽略localhost
- CreateDocumentCollectionIfNotExistsAsync并不总是有效
- 元素下面的元素在Azure中无法识别
- 从用于Google API的Azure网站中的p12证书生成X509Certificate2时出现502错误