2016-10-05 4 views
2

Microsoft.Azure.DocumentDBを使用して、azure documentDBにコレクションを作成するサンプルコードがいくつかあります。しかし、C#を使用して異なるパーティションモードでコレクションを作成する方法に関する情報は見つかりませんでした。異なるパーティションモードのAzure DocumentDBでコレクションを作成

ポータルからは、シングルパーティションとパーティションの2つのモードがあります。

Microsoft.Azure.DocumentDBを使用してコレクションを作成するときに、他のものを使用できますか?

答えて

3

Document DB Partitioningをサポートするには、SDKバージョン1.6.0以上が必要です。 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 値を指定する必要があります。スループットは100の倍数であるため、10,100以上でなければなりません。

OfferThroughputを20000未満に設定すると、コレクションはシングルパーティションになります。

+0

Aramのレスポンスのちょっとした修正 - スループットが10000未満に設定されていると、コレクションに単一パーティションがあると思います。詳細はhttps://github.com/Azure/azure-content/blob/master/articles/documentdb/documentdb-partition-data.mdを参照してください。 –

関連する問題