Skip to content

DrDonoso/Cosmos-Autoscale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CosmosDB Autoscale

Tool for autoscaling cosmos.

Usage

First of all initialize CustomDocumentClient with Url and Authkey.

var customDocumentClient = CustomDocumentClient.Of("Url", "Authkey");

If you initialize it like this, you will have default settings if you use the common executeasync. To Initialize with settings:

var customConfiguration = new CustomConfiguration {
	MaxRetries = 10,
	MinThroughput = 1000,
	MaxThroughput = 10000,
	ScaleUpBatch = 200,
	ScaleDownBatch = 100
};
var customDocumentClient = CustomDocumentClient.Of("Url", "Authkey", customConfiguration);

Client (Scale up)

Once you have the client initialized, you should use Execute or ExecuteAsync for all the requests. There is two methods of Execute in order to use the common configuration or sending params if you have your environment configured.

Task<T> ExecuteAsync<T>(Func<IDocumentClient, Task<T>> func, string database, string collection, int retries = 0);
Task<T> ExecuteAsync<T>(Func<IDocumentClient, Task<T>> func, string database, string collection, int minThroughput, int maxThroughput, int scaleUpBatch, int retries = 0);

Example

await _customDocumentClient.ExecuteAsync(x => x.UpsertDocumentAsync(collectionUri, data), database, collection).ConfigureAwait(false);

Azure function (Scale down)

For now, there is only one method for scale down all the collections with the current configuration (Working on it).

await customClient.ScaleDownAll().ConfigureAwait(false);

Releases

No releases published

Packages

No packages published

Languages