2

I have a cosmosDB that had 4 containers and 400RUs provisioned at the database level. I added 2 containers and without warning the provisioned RUs was increased to 600.

The document below explains why this happened. Each container above the 4th requires a minimum extra 100RUs. I have tight budget restrictions so I deleted 2 containers but I could not find a way to reduce the minimum provisioned throughput as the dropdown for provisioning throughput only allows increases. Is there a way to reduce throughput?

https://docs.microsoft.com/en-us/azure/cosmos-db/set-throughput

1

As mentioned in the document,you could reduce throughput settings by using cosmos db sdk. For example, i test java sdk to reduce my container throughput setting. Please refer to below code:

import com.microsoft.azure.documentdb.*;

import java.util.Iterator;

public class ChangeRUTest {

    static private String YOUR_COSMOS_DB_ENDPOINT ="https://***.documents.azure.com:443/";
    static private String YOUR_COSMOS_DB_MASTER_KEY="***";

    public static void main(String[] args) throws DocumentClientException {

        DocumentClient client = new DocumentClient(
                YOUR_COSMOS_DB_ENDPOINT,
                YOUR_COSMOS_DB_MASTER_KEY,
                new ConnectionPolicy(),
                ConsistencyLevel.Session);

        String collectionLink ="dbs/test/colls/one";

        String collectionResourceId = client.readCollection(collectionLink, null).getResource().getResourceId();

        // find offer associated with this collection
        Iterator<Offer> it = client.queryOffers(
                String.format("SELECT * FROM r where r.offerResourceId ='%s'", collectionResourceId), null).getQueryIterator();

        Offer offer = it.next();

        System.out.println(offer.getContent().getInt("offerThroughput"));

        // update the offer
        int newThroughput = 400;
        offer.getContent().put("offerThroughput", newThroughput);
        client.replaceOffer(offer);

    }
}
  • Do you know a method for Cosmos DB with MongoDB Api? – Hamish Anderson Apr 18 at 2:35
  • @HamishAnderson Tried to find for you. – Jay Gong Apr 18 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.