簡體   English   中英

使用不同的分區模式在Azure DocumentDB中創建集合

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM