Skip to content

Conversation

@andrewmathew1
Copy link
Contributor

Description

Priority-based execution is a capability which allows users to specify priority for the request sent to Azure Cosmos DB. Based on the priority specified by the user, if there are more requests than the configured RU/s in a second, then Azure Cosmos DB will throttle low priority requests to allow high priority requests to execute. Previously this was only available at the request level now entire clients can be set to a low or high priority level. The request priority level will take precedence over the client priority level in case both are set.

Copilot AI review requested due to automatic review settings November 10, 2025 19:37
@andrewmathew1 andrewmathew1 requested a review from a team as a code owner November 10, 2025 19:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds client-level priority configuration for Azure Cosmos DB clients (both sync and async), allowing users to set a default priority level for all requests made by a client. This complements the existing request-level priority feature, with request-level priority taking precedence when both are set.

  • Added priority_level parameter to CosmosClient constructors in both sync and async implementations
  • Client-level priority is stored in default headers and applied to all requests
  • Comprehensive documentation and examples demonstrating client-level priority, request-level priority, and precedence behavior

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py Implements client-level priority by adding priority_level parameter and storing it in default_headers
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py Async implementation of client-level priority, mirroring the sync implementation
sdk/cosmos/azure-cosmos/tests/test_headers.py Adds tests for client-level priority and request-level precedence in sync client
sdk/cosmos/azure-cosmos/tests/test_headers_async.py Adds tests for client-level priority and request-level precedence in async client
sdk/cosmos/azure-cosmos/samples/examples.py Demonstrates client-level priority usage and precedence with practical examples
sdk/cosmos/azure-cosmos/samples/examples_async.py Demonstrates async client-level priority usage and precedence with practical examples

@andrewmathew1
Copy link
Contributor Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Member

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments but overall the changes seem to be good, thanks Andrew!

@andrewmathew1
Copy link
Contributor Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

andrewmathew1 and others added 2 commits November 12, 2025 08:40
Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
@andrewmathew1 andrewmathew1 changed the title Added priority_level for Sync and Async Clients Added Priority Based Execution for Sync and Async Clients Nov 12, 2025
@andrewmathew1
Copy link
Contributor Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants