Deploying Azure Cosmos Mongo Collection with dedicated throughput using Fluent API

We created an application for deploying Azure Cosmos DB Accounts with Mongo-API on demand by using Azure libraries for .Net https://github.com/Azure/azure-libraries-for-net.

For this usecase it's required to create the databases and the collections using this API, too. Otherwise the MongoClient will create those resources automatically if they don't exists. If MongoClient creates those resources, you can't select the throughput and this will cost you much money.

Here is an example how to set the trhoughput on MongoDBCollection.

MongoDBCollectionResource mongoDBCollectionResource = new MongoDBCollectionResource(collectionName);

                var mongoCollectionParams = new MongoDBCollectionCreateUpdateParameters()
                {
                    Options = new Dictionary<string, string>()
                    {
                    },
                    Location = region.Name,
                    Resource = mongoDBCollectionResource
                };

                    mongoCollectionParams.Options.Add("throughput", collectionThroughput.ToString());

                await azure.CosmosDBAccounts.Manager.Inner.MongoDBResources.CreateUpdateMongoDBCollectionWithHttpMessagesAsync(
                    resourceGroup,
                    accountName,
                    databaseName,
                    collectionName,
                    mongoCollectionParams);

The interesting part here is mongoCollectionParams.Options.Add("throughput", collectionThroughput.ToString());.

You can use the same logic for deploying MongoDB databases through adding the throughput parameter.