Python example for creating container with AutoScale enabled
Hello,
I'm having trouble creating a container with AutoScale enabled using the Python SDK:
database = client.get_database_client(database_id) container = database.create_container_if_not_exists( id=container_id, partition_key=partition_key, offer_throughput=4000)
I have successfully created an AutoScale container using the node.js sdk:
await client .database(databaseId) .containers.createIfNotExists( { id: containerId, partitionKey, maxThroughput: 4000 } );
I'm assuming Python's 'offer_throughput' is equivalent to node's 'maxThroughput'. I'm unable to find a max_throughput in the documentation. Any help is much appreciated.
Thanks
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 3ab1e9e0-c5b1-b219-ee39-4252926aff6f
- Version Independent ID: a8f6ada3-9310-d2f9-401b-72b69bf4d76a
- Content: Provision autoscale throughput in Azure Cosmos DB SQL API
- Content Source: articles/cosmos-db/sql/how-to-provision-autoscale-throughput.md
- Service: cosmos-db
- Sub-service: cosmosdb-sql
- GitHub Login: @deborahc
- Microsoft Alias: dech
Thank you for the detailed question. We are currently investigating and will update you when we have accurate information to provide.
Hello again, I'm actually seeing that the Provisioning of Autoscale containers is a limitation in the current SDK. Can anyone confirm this and possible offer a work around? Thanks
@deborahc could you please share your input regarding the above request.
#reassign:seesharprun
Yes, this is a feature not currently supported in the Python SDK. You can work around this by using the REST API. If you need assistance with using the REST API, please visit our Q&A forums.
#please-close
Thanks @seesharprun . Do we know if/when Autoscale will be added to the Python SDK? While using the rest api is an option, creating the Authorization string required by the rest call seems a bit complicated (looking at this article). It would be helpful if they had examples for Python seeing as Py folks will be forced to use the REST API if they need Autoscale. Thx
Unfortunately, I do not have a timeline on when Autoscale will be added to the Python SDK.
Can we update this thread when it more info becomes available? Thanks.
Can we have update on this when autoscale option wil be available in python SDK
For anyone still looking for container autoscale option, it is possible to set the autoscaling option through ThroughputProperties
Something like this:
from azure.cosmos.offer import ThroughputProperties
throughput_properties = ThroughputProperties({"auto_scale_max_throughput": 1000})
container = database.create_container_if_not_exists( id=container_id, partition_key=partition_key, offer_throughput=throughput_properties)
For existing containers the throughput can be changed using:
container.replace_throughput(throughput_properties)