C#:如何以编程方式扩展现有 DocumentDB 集合的定价层?

C#: How do you programmatically scale the Pricing Tier for an existing DocumentDB collection?

我希望能够从 C# 中修改现有 DocumentDB 集合的 OfferType(例如定价层 S2S3 等),但我没有看到Microsoft.Azure.Documents.DocumentCollection class 的任何成员,这将促进这一点。

是否有另一种方法可以提供此功能?

请参阅此代码片段,了解如何使用 .NET SDK 更改 DocumentDB 集合的性能级别

https://azure.microsoft.com/en-gb/documentation/articles/documentdb-performance-levels/#changing-performance-levels-using-the-net-sdk

// Query the "offers" feed to retrieve the offer for the collection
Offer offer = client.CreateOfferQuery()
                    .Where(r => r.ResourceLink == "collection selfLink")    
                    .AsEnumerable()
                    .SingleOrDefault();

//Change the offer type to S1, S2 or S3
offer.OfferType = "S3";

//Now update the "offer" resource
Offer updated = await client.ReplaceOfferAsync(offer);

这是 V2 报价类型的更新示例,可控制 DTU 和新的每分钟 RU 标志:

var collectionLink = UriFactory.CreateDocumentCollectionUri("databaseId","collectionName");
var response = await Client.ReadDocumentCollectionAsync(collectionLink);
var collection = response.Resource;

var results = await Client.CreateOfferQuery()
            .Where(o => o.ResourceLink == collection.SelfLink)
            .AsDocumentQuery()
            .ExecuteNextAsync<OfferV2>();

var offer = results.FirstOrDefault();

var updatedOffer = new OfferV2(offer, offerThroughput:800, offerEnableRUPerMinuteThroughput:true);

await Client.ReplaceOfferAsync(updatedOffer);

另请参阅: https://msdn.microsoft.com/en-us/library/microsoft.azure.documents.offerv2.aspx