Search code examples
azure-functionsazure-cosmosdb

Update Cosmos throughput via python SDK


Our use case is we have a Cosmos DB with a bunch of documents. These are exposed via an function API. The usage of the API is low but each night , we need to insert a big batch of documents using data factory. When this process runs, it consumes all the Request units provisioned (400-4000 RU/s). We are therefore looking for a solution where we can update the throughput programmatically, execute the upload of documents, and then bring the throughout down again.

We are looking to do this using python SDK via function execution. I found sample code Update throughput using python online but this seems to only work when the throughput is manually provisioned. When I tried the same code with an auto scaled throughout, there was no error but it did not get updated either.

Can someone point me to some sample code where I can update the throughput when it is set to auto scale?


Solution

  • Can someone point me to some sample code where I can update the throughput when it is set to auto scale?

    I looked up the SDK code here and I believe the ability to change auto-scale throughput is not available in the current version of SDK (version 4.2.0).

    There's also an open issue on Github regarding the same: https://github.com/Azure/azure-sdk-for-python/issues/17518. I would suggest you track that issue as to when this feature will be available in the SDK.