Manage Azure Table Storage with Python
Python skill for Azure Tables SDK: entity CRUD, partition-scoped queries, batch transactions, and async access to Azure/Cosmos tables.
Why it matters
Interact with Azure Storage Tables or Cosmos DB Table API using Python. Perform CRUD operations on tables and entities, and execute queries.
Outcomes
What it gets done
Connect to Azure Table Storage or Cosmos DB.
Create, read, update, and delete tables and entities.
Query entities with various filters and select specific properties.
Utilize batch operations for efficient data manipulation.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-azure-data-tables-py | bash Overview
Azure Tables SDK for Python
Covers the Azure Tables SDK for Python: TableServiceClient/TableClient, entity CRUD by PartitionKey/RowKey, partition-scoped and parameterized queries, batch transactions within a partition, and an async client for high throughput. Use when building on Azure Storage Tables or Cosmos DB Table API in Python; partition key design and partition-scoped querying are the key performance levers.
What it does
This skill covers the Azure Tables SDK for Python, a NoSQL key-value store usable against either Azure Storage Tables or the Cosmos DB Table API. It centers on two client types: TableServiceClient for creating, deleting, and listing tables, and TableClient for entity CRUD and queries against a specific table. Every entity requires a PartitionKey and RowKey, which together form its unique identifier. Entity creation supports create_entity (fails if the entity already exists) or upsert_entity (creates or replaces), and lookups by key via get_entity are described as the fastest retrieval path. Updates support replace mode (overwrites the whole entity) or merge mode (updates only the specified fields), and deletion is by partition/row key pair.
Querying covers filtering within a single partition (the efficient path), filtering by additional properties with OData-style expressions (quantity gt 3), parameterized queries using @-prefixed placeholders for safer filtering, selecting specific properties to reduce payload size, and listing all entities across partitions - flagged as something to use sparingly given the cost of cross-partition scans. Batch operations via submit_transaction group multiple create/upsert operations into a single atomic call, but only work within a single partition; a TableTransactionError is raised if the batch fails. An async client variant mirrors the same operations using azure.data.tables.aio and azure.identity.aio, suited to high-throughput scenarios with async with/async for patterns.
A data-type mapping table documents how Python types map to Table Storage types: str to String, int to Int64, float to Double, bool to Boolean, datetime to DateTime, bytes to Binary, and UUID to Guid.
When to use - and when NOT to
Use this when storing and querying structured, semi-schema-flexible data in Azure Storage Tables or Cosmos DB's Table API from Python. Best practices are explicit: design partition keys around actual query patterns and even data distribution, query within a partition whenever possible since cross-partition queries are expensive, use batch operations for multiple entities sharing a partition, prefer upsert_entity for idempotent writes, use parameterized queries to prevent injection, keep individual entities under the 1MB size limit, and reach for the async client in high-throughput workloads.
Inputs and outputs
Install with:
pip install azure-data-tables azure-identity
Configuration is AZURE_STORAGE_ACCOUNT_URL for Azure Storage Tables or COSMOS_TABLE_ENDPOINT for the Cosmos DB Table API, with DefaultAzureCredential as the authentication method shown throughout. Inputs are entity dictionaries keyed by PartitionKey/RowKey plus arbitrary properties; outputs are entity objects or iterables of entities from query calls.
Integrations
Built on Azure Identity's DefaultAzureCredential for authentication, and works interchangeably against either Azure Storage Tables or Cosmos DB's Table API depending on which endpoint is configured.
Who it's for
Python developers building applications on Azure Storage Tables or Cosmos DB Table API who need concrete patterns for entity CRUD, efficient partition-scoped querying, batch transactions, and async access at scale.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.