4

Is it possible to autoscale the CosmosDB throughput using either c# or Azure Automation? Please provide a sample example.

Pragna Gopa
  • 726
  • 3
  • 10
scorpion5211
  • 1,020
  • 2
  • 13
  • 33

1 Answers1

6

Storage is automatically scaled. Here is the code to change the throughput automatically

//Fetch the resource to be updated
Offer offer = client.CreateOfferQuery()
                  .Where(r => r.ResourceLink == collection.SelfLink)    
                  .AsEnumerable()
                  .SingleOrDefault();

// Set the throughput to 2500 request units per second
offer = new OfferV2(offer, 2500);

//Now persist these changes to the database by replacing the original resource
await client.ReplaceOfferAsync(offer);

See more here: https://learn.microsoft.com/en-us/azure/cosmos-db/set-throughput

HTH

Rafat Sarosh
  • 989
  • 7
  • 16