{"id":2404,"library":"azure-cosmosdb-table","title":"Azure Cosmos DB Table Client Library (Legacy)","description":"This is an older client library for interacting with Azure Cosmos DB Table API and Azure Table Storage. It provides functionalities for creating, managing, and querying tables and entities. As of version 1.0.6, it is considered a legacy library, with the actively maintained `azure-data-tables` package being the recommended replacement. The library is no longer actively developed.","status":"deprecated","version":"1.0.6","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-cosmosdb-python","tags":["azure","cosmosdb","table storage","nosql","deprecated","legacy"],"install":[{"cmd":"pip install azure-cosmosdb-table","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"The Table SDK was split from the `azure-storage` namespace and moved to `azure.cosmosdb.table` in this library's version 1.0.0.","wrong":"from azure.storage.table import TableService","symbol":"TableService","correct":"from azure.cosmosdb.table import TableService"},{"symbol":"Entity","correct":"from azure.cosmosdb.table import Entity"}],"quickstart":{"code":"import os\nfrom azure.cosmosdb.table import TableService, Entity\n\n# Set these environment variables or replace with actual values\n# AZURE_STORAGE_CONNECTION_STRING (preferred) or AZURE_STORAGE_ACCOUNT_NAME and AZURE_STORAGE_ACCOUNT_KEY\nconnection_string = os.environ.get(\"AZURE_STORAGE_CONNECTION_STRING\", \"DefaultEndpointsProtocol=https;AccountName=your_account_name;AccountKey=your_account_key;EndpointSuffix=core.windows.net\")\naccount_name = os.environ.get(\"AZURE_STORAGE_ACCOUNT_NAME\", \"your_account_name\")\naccount_key = os.environ.get(\"AZURE_STORAGE_ACCOUNT_KEY\", \"your_account_key\")\n\n# Initialize the TableService client\n# If connection string is not valid, try with account name/key\nif \"DefaultEndpointsProtocol\" in connection_string and \"your_account_name\" not in connection_string:\n    table_service = TableService(connection_string=connection_string)\nelse:\n    table_service = TableService(account_name=account_name, account_key=account_key)\n\ntable_name = \"mytesttable\"\n\ntry:\n    # Create table if it doesn't exist\n    print(f\"Creating table '{table_name}' if it doesn't exist...\")\n    table_service.create_table(table_name)\n    print(f\"Table '{table_name}' created or already exists.\")\n\n    # Insert an entity\n    task = {'PartitionKey': 'tasks', 'RowKey': '1', 'description': 'Learn Python SDK', 'priority': 100}\n    print(f\"Inserting entity: {task}\")\n    table_service.insert_entity(table_name, task)\n    print(\"Entity inserted.\")\n\n    # Retrieve an entity\n    print(f\"Retrieving entity with PartitionKey='tasks', RowKey='1'\")\n    retrieved_task = table_service.get_entity(table_name, 'tasks', '1')\n    print(f\"Retrieved entity: {retrieved_task['description']}, Priority: {retrieved_task['priority']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure your Azure Storage/Cosmos DB connection details are correct and the account has table API enabled.\")\n\n# Optional: Clean up the table\n# try:\n#     print(f\"Deleting table '{table_name}'...\")\n#     table_service.delete_table(table_name)\n#     print(f\"Table '{table_name}' deleted.\")\n# except Exception as e:\n#     print(f\"Error deleting table: {e}\")","lang":"python","description":"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."},"warnings":[{"fix":"Migrate to `pip install azure-data-tables` and update import statements and client initialization. Refer to official Azure SDK migration guides.","message":"This 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.","severity":"breaking","affected_versions":"All versions"},{"fix":"Switch to the actively maintained `azure-data-tables` library.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update imports from `from azure.storage.table import ...` to `from azure.cosmosdb.table import ...`.","message":"Prior 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`.","severity":"gotcha","affected_versions":"< 1.0.0 (of `azure-storage`)"},{"fix":"Understand 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.","message":"While 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For asynchronous operations and better integration with modern Python async patterns, migrate to `azure-data-tables`, which offers full async/await support.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}