Install & Compatibility
Where this runs
tested against v1.0.6 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.574s · 40.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 0.514s · 41MB
39MB installed
● package 39MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TableService
✓ from azure.cosmosdb.table import TableService
✗ from azure.storage.table import TableService
The Table SDK was split from the `azure-storage` namespace and moved to `azure.cosmosdb.table` in this library's version 1.0.0.
Entity
✓ from azure.cosmosdb.table import Entity
This quickstart demonstrates how to initialize the `TableService` client, create a table, insert an entity, and retrieve an entity using connection string or account credentials. Remember to set `AZURE_STORAGE_CONNECTION_STRING` or `AZURE_STORAGE_ACCOUNT_NAME` and `AZURE_STORAGE_ACCOUNT_KEY` environment variables.
import os
from azure.cosmosdb.table import TableService, Entity
# Set these environment variables or replace with actual values
# AZURE_STORAGE_CONNECTION_STRING (preferred) or AZURE_STORAGE_ACCOUNT_NAME and AZURE_STORAGE_ACCOUNT_KEY
connection_string = os.environ.get("AZURE_STORAGE_CONNECTION_STRING", "DefaultEndpointsProtocol=https;AccountName=your_account_name;AccountKey=your_account_key;EndpointSuffix=core.windows.net")
account_name = os.environ.get("AZURE_STORAGE_ACCOUNT_NAME", "your_account_name")
account_key = os.environ.get("AZURE_STORAGE_ACCOUNT_KEY", "your_account_key")
# Initialize the TableService client
# If connection string is not valid, try with account name/key
if "DefaultEndpointsProtocol" in connection_string and "your_account_name" not in connection_string:
table_service = TableService(connection_string=connection_string)
else:
table_service = TableService(account_name=account_name, account_key=account_key)
table_name = "mytesttable"
try:
# Create table if it doesn't exist
print(f"Creating table '{table_name}' if it doesn't exist...")
table_service.create_table(table_name)
print(f"Table '{table_name}' created or already exists.")
# Insert an entity
task = {'PartitionKey': 'tasks', 'RowKey': '1', 'description': 'Learn Python SDK', 'priority': 100}
print(f"Inserting entity: {task}")
table_service.insert_entity(table_name, task)
print("Entity inserted.")
# Retrieve an entity
print(f"Retrieving entity with PartitionKey='tasks', RowKey='1'")
retrieved_task = table_service.get_entity(table_name, 'tasks', '1')
print(f"Retrieved entity: {retrieved_task['description']}, Priority: {retrieved_task['priority']}")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your Azure Storage/Cosmos DB connection details are correct and the account has table API enabled.")
# Optional: Clean up the table
# try:
# print(f"Deleting table '{table_name}'...")
# table_service.delete_table(table_name)
# print(f"Table '{table_name}' deleted.")
# except Exception as e:
# print(f"Error deleting table: {e}")
Debug
Known issues
breakingThis library (`azure-cosmosdb-table`) is considered legacy and has been largely superseded by the `azure-data-tables` library. Microsoft strongly recommends migrating to `azure-data-tables` for new development and existing applications for better performance, modern features (like full async support), and continued maintenance.fixMigrate to `pip install azure-data-tables` and update import statements and client initialization. Refer to official Azure SDK migration guides.
affects: All versions
gotchaThe GitHub repository for `azure-cosmos-table-python` (which contains `azure-cosmosdb-table`) was archived on July 14, 2023, making it read-only. This confirms its end-of-life status, indicating no further updates or bug fixes will be provided for this library.fixSwitch to the actively maintained `azure-data-tables` library.
affects: All versions
gotchaPrior to version 1.0.0, table-related classes were part of the `azure.storage` namespace. They were moved to `azure.cosmosdb.table` in this library. Users migrating from older `azure-storage` versions might encounter `ImportError`.fixUpdate imports from `from azure.storage.table import ...` to `from azure.cosmosdb.table import ...`.
affects: < 1.0.0 (of `azure-storage`)
gotchaWhile this SDK can connect to both Azure Table Storage and Azure Cosmos DB's Table API, these underlying services have significant differences in performance, scalability, indexing, and cost models. Unawareness can lead to unexpected costs or performance issues.fixUnderstand the distinctions between Azure Table Storage and Azure Cosmos DB's Table API. For new projects, `azure-data-tables` is the recommended client library which clearly targets both.
affects: All versions
gotchaThis library primarily offers synchronous APIs, lacking modern `async`/`await` support. This can impact performance and responsiveness in modern I/O-bound applications compared to the `azure-data-tables` library.fixFor asynchronous operations and better integration with modern Python async patterns, migrate to `azure-data-tables`, which offers full async/await support.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'azure.cosmosdb'
The 'azure-cosmosdb-table' package is not installed in the environment.
fixInstall the package using 'pip install azure-cosmosdb-table'.
ImportError: cannot import name 'AccessTokenInfo' from 'azure.core.credentials'
The 'AccessTokenInfo' class was introduced in 'azure-core' version 1.33.0, and the current version is outdated.
fixUpgrade 'azure-core' to version 1.33.0 or later using 'pip install --upgrade azure-core'.
ImportError: cannot import name 'Sequence' from 'collections'
In Python 3.10 and later, 'Sequence' has been moved from 'collections' to 'collections.abc'.
fixUpdate the import statement to 'from collections.abc import Sequence'.
ModuleNotFoundError: No module named 'azure.cosmos'
The 'azure-cosmos' package is not installed in the environment.
fixInstall the package using 'pip install azure-cosmos'.
ImportError: cannot import name 'BlobService' from 'azure.storage.blob.blobservice'
The 'BlobService' class has been deprecated and removed in newer versions of the 'azure-storage' package.
fixUse 'BlobServiceClient' from 'azure.storage.blob' instead.
Upgrade
Version history
1.0.6latest on PyPI · released Oct 25, 2019
Audit
Dependencies
No dependency data recorded yet.