Skip to content

Instantly share code, notes, and snippets.

@tombiddulph
Created September 1, 2020 16:25
Show Gist options
  • Select an option

  • Save tombiddulph/6c7beb668c36c8c3a455bb431fa560e1 to your computer and use it in GitHub Desktop.

Select an option

Save tombiddulph/6c7beb668c36c8c3a455bb431fa560e1 to your computer and use it in GitHub Desktop.
Configuring Cosmos throughput
CosmosClient client = new CosmosClient(connectionString);
Database db = client.GetDatabase("test-db");
Container container = db.GetContainer("test-container");
const int rus = 1000;
ThroughputResponse manualDbThroughput = await db.ReplaceThroughputAsync(ThroughputProperties.CreateManualThroughput(rus));
ThroughputResponse autoDbThroughput = await db.ReplaceThroughputAsync(ThroughputProperties.CreateAutoscaleThroughput(rus));
ThroughputResponse manualContainerThroughput = await container.ReplaceThroughputAsync(ThroughputProperties.CreateManualThroughput(rus));
ThroughputResponse autoContainerThroughput = await container.ReplaceThroughputAsync(ThroughputProperties.CreateAutoscaleThroughput(rus));
@gmantri
Copy link

gmantri commented Sep 2, 2020

Thanks for this. However when I try to change from "Manual" to "Autoincrement" for a database, I get a 400 error. This is the error message I am getting:

{"code":"BadRequest","message":"Message: {\"Errors\":[\"x-ms-cosmos-migrate-offer-to-autopilot must be supplied and offercontent must not contain autopilotSettings for migration from manual throughput to autoscale.\"]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment