我希望能够在C#中修改现有DocumentDB集合的OfferType(例如,定价等级S2
,S3
等),但我不会这样做。看到Microsoft.Azure.Documents.DocumentCollection
类的任何成员都会为此提供便利。
是否有其他方法可以提供此功能?
答案 0 :(得分:3)
请参阅此代码段,了解如何使用.NET SDK更改DocumentDB集合的性能级别
// 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);
答案 1 :(得分:1)
这是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