'How to create a CosmosDB Table with autoscale throughput in c#?
I am trying to create a table in a Cosmos DB with autoscale throughput configuration but I see the CloudTable CreateIfNotExists API has no option to specify autoscale while creating a table. How can I achieve the same?
public virtual bool CreateIfNotExists(IndexingMode indexingMode, int? throughput = null);
public virtual bool CreateIfNotExists(TableRequestOptions requestOptions = null, OperationContext operationContext = null, string serializedIndexingPolicy = null, int? throughput = null);
Solution 1:[1]
I am author of implementation of Auto Scaling Azure Cosmos DB, because of lacking build in auto-scaling at that time https://github.com/JanuszNowak/Janono.Azure.DocumentsDB.Scale. Now Azure Cosmos DB support build in autoscaling https://docs.microsoft.com/en-us/azure/cosmos-db/provision-throughput-autoscale.
Solution 2:[2]
Looking at the release notes for Cosmos DB Table SDK (here and here), I believe that support for autoscale is still not there in the latest SDKs at this time (2.0.0-preview for .Net Standard).
As a workaround, what you can do is make use of Cosmos DB SQL API SDK (version 3.0 or more) and create a container with autoscale throughput. A container is essentially a table. You can find code sample to do the same here: https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-provision-autoscale-throughput?tabs=api-async#azure-cosmos-db-net-v3-sdk-for-sql-api.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Janusz Nowak |
| Solution 2 | Gaurav Mantri |
