Last active
August 1, 2019 00:39
-
-
Save deborahc/499ff7c21382dd55969277f667323bb7 to your computer and use it in GitHub Desktop.
Scale throughput of a container in Azure Cosmos DB .NET SDK V3 (GA)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scaling throughput (RU/s) using V3 SDK | |
static async Task ScaleThroughputDemo_SDKVersion3() | |
{ | |
// Get reference to container | |
var container = cosmosClient.GetContainer(databaseId, containerId); | |
// Read value of current throughput (RU/s) | |
var currentThroughput = await container.ReadThroughputAsync(); | |
var newThroughput = (int)currentThroughput * 2; | |
// Replace throughput with new value | |
var throughputResponse = await container.ReplaceThroughputAsync(newThroughput); | |
} | |
// For comparison, using V2 SDK | |
static async Task ScaleThroughputDemo_SDKVersion2() | |
{ | |
var client = new DocumentClient(new Uri(endpointUrl), authorizationKey); | |
// Read value of current throughput (RU/s) | |
Offer offer = client.CreateOfferQuery().Where(o => o.ResourceLink == collection.SelfLink).AsEnumerable().Single(); | |
// Replace throughput with new value | |
Offer replaced = await client.ReplaceOfferAsync(new OfferV2(offer, 500)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment