Registry / azure / azure-mgmt-cosmosdb

azure-mgmt-cosmosdb

JSON →
library10.0.0pypypi✓ verified 25d ago

The Microsoft Azure Cosmos DB Management Client Library for Python provides capabilities to manage Azure Cosmos DB resources, such as creating, updating, and deleting Cosmos DB accounts, databases, and containers. It interacts with the Azure Cosmos DB resource provider (control plane). The current version is 9.9.0, and it generally follows a regular release cadence as part of the Azure SDK for Python updates.

pip install azure-mgmt-cosmosdb azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-COSMOSD
A
azure-mgmt-cosmosdb
azurepythonv10.0.0
Install
4.2s avg
Import
773ms
Disk
50MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v10.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.810s · 50.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 0.736s · 51MB
50MB installed
● package 50MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CosmosDBManagementClient
from azure.mgmt.cosmosdb import CosmosDBManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
CosmosDB
from azure.mgmt.cosmosdb import CosmosDBManagementClient
from azure.mgmt.cosmosdb.cosmos_db import CosmosDB
In older versions (e.g., prior to 0.8.0), some top-level client classes were accessible via a submodule. Current versions centralize client imports directly under `azure.mgmt.cosmosdb`.
models.*
from azure.mgmt.cosmosdb.models import <ModelName>
from azure.mgmt.cosmosdb.models.<model_name> import <ModelName>
Prior to 0.8.0, some models were incorrectly importable from submodules. Direct import from `azure.mgmt.cosmosdb.models` is the correct pattern.
operations.*
from azure.mgmt.cosmosdb.operations import <OperationGroup>
from azure.mgmt.cosmosdb.operations.<operation_group_name> import <OperationGroup>
Similar to models, operations groups were incorrectly importable from submodules in older versions. Direct import from `azure.mgmt.cosmosdb.operations` is the correct pattern.

Initializes the `CosmosDBManagementClient` using `DefaultAzureCredential` and lists existing Cosmos DB accounts. Ensure `AZURE_SUBSCRIPTION_ID` and other Azure authentication environment variables (like `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`) are set.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.cosmosdb import CosmosDBManagementClient # Set these environment variables for authentication # AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET for service principal # AZURE_SUBSCRIPTION_ID subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID") if subscription_id == "YOUR_SUBSCRIPTION_ID": print("Please set the AZURE_SUBSCRIPTION_ID environment variable or replace 'YOUR_SUBSCRIPTION_ID' in the code.") exit() # Authenticate using DefaultAzureCredential # This will try to authenticate using various methods (env vars, managed identity, CLI, etc.) credential = DefaultAzureCredential() # Create a CosmosDB management client client = CosmosDBManagementClient(credential, subscription_id) # Example: List all Cosmos DB accounts in the subscription print("Listing Cosmos DB accounts...") for account in client.database_accounts.list(): print(f" - {account.name} (Resource Group: {account.resource_group})") print("Client initialized successfully and listed accounts.")
Debug
Known issues
breakingVersion 9.9.0 introduced several breaking changes including removal of parameters from models (e.g., `BackupResource`, `CommandPostBody`, `ServiceResourceCreateUpdateParameters`) and deletion/renaming of client operation groups and enum values. Review release notes carefully when upgrading.
fix
Consult the official release notes and update your code to reflect the new model structures and client operations.
affects: >=9.9.0
breakingOlder versions (pre ~0.8.0) had module reorganization which changed import paths for `CosmosDB` client and direct access to models and operations submodules. This can cause `ImportError` for legacy code.
fix
Update import statements to use the streamlined `from azure.mgmt.cosmosdb import <Client/Class>` pattern and access models/operations via the client object or `azure.mgmt.cosmosdb.models`/`azure.mgmt.cosmosdb.operations` directly.
affects: <0.8.0 to current
gotcha`DefaultAzureCredential` relies on specific environment variables for non-interactive/service principal authentication (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`). Incorrect or missing configuration will lead to authentication failures.
fix
Ensure all necessary Azure authentication environment variables are correctly set for your chosen authentication method before initializing `DefaultAzureCredential`.
affects: All versions using `azure-identity`
deprecatedSupport for Python 2.7 officially ended on January 1, 2022. Using `azure-mgmt-cosmosdb` with Python 2.7 is unsupported and will likely lead to issues.
fix
Upgrade your Python environment to Python 3.9 or newer. The library requires Python >=3.9.
affects: <=3.8
gotchaSynchronous I/O operations are generally discouraged and can be blocked by default in newer Azure SDKs. While primarily affecting data plane SDKs and .NET EF Core, it's a good practice to use async patterns or ensure long-running management operations are handled with polling for a responsive application.
fix
Embrace asynchronous programming patterns (`async`/`await`) where possible, especially for I/O bound operations. For management plane operations, utilize the built-in polling mechanisms for long-running operations.
affects: All versions
Upgrade
Version history
10.0.0latest on PyPI · released Jul 3, 2026
Audit
Dependencies
azure-identityrequiredRequired for Azure Active Directory token authentication, used by DefaultAzureCredential.
pythonrequiredMinimum Python version supported.
Agent activity
36 hits · last 30 days
node
32
OpenAI (training)
1
Resources
azure-mgmt-cosmosdb — pip install azure-mgmt-cosmosdb · libregistry