azure-data-tables-py – skill DevOps & Hạ tầng cho agent AI
SDK Azure Tables cho Python (Storage và Cosmos DB). Dùng cho lưu trữ key-value NoSQL, CRUD thực thể và thao tác batch.
Cài skill azure-data-tables-py bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-data-tables-py-7a27d.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /azure-data-tables-py – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-data-tables-py-7a27d.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $azure-data-tables-py – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-data-tables-py-7a27d.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /azure-data-tables-py – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/azure-data-tables-py-7a27d.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /azure-data-tables-py – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Azure Tables SDK for Python
NoSQL key-value store for structured data (Azure Storage Tables or Cosmos DB Table API).
Installation
pip install azure-data-tables azure-identityEnvironment Variables
# Azure Storage Tables
AZURE_STORAGE_ACCOUNT_URL=https://<account>.table.core.windows.net
# Cosmos DB Table API
COSMOS_TABLE_ENDPOINT=https://<account>.table.cosmos.azure.comAuthentication
from azure.identity import DefaultAzureCredential
from azure.data.tables import TableServiceClient, TableClient
credential = DefaultAzureCredential()
endpoint = "https://<account>.table.core.windows.net"
# Service client (manage tables)
service_client = TableServiceClient(endpoint=endpoint, credential=credential)
# Table client (work with entities)
table_client = TableClient(endpoint=endpoint, table_name="mytable", credential=credential)Client Types
| Client | Purpose |
|--------|---------|
| TableServiceClient | Create/delete tables, list tables |
| TableClient | Entity CRUD, queries |
These are independent fragments. Confirm account/table/partition/row and exact write/delete scope; protect existing entities, use ETags/match conditions for concurrent changes and reconcile timeouts before retries. Storage Table and Cosmos Table authentication/feature/transaction limits differ; verify the selected endpoint rather than assuming one identity configuration fits both. Bound queries/pages/bytes and do not log entity contents. Close async credentials as well as clients on failure. Currency double examples are illustrative; choose exact asset units for money.
Table Operations
# Create table
service_client.create_table("mytable")
# Create if not exists
service_client.create_table_if_not_exists("mytable")
# Delete table
service_client.delete_table("mytable")
# List tables
for table in service_client.list_tables():
print(table.name)
# Get table client
table_client = service_client.get_table_client("mytable")Entity Operations
Important: Every entity requires PartitionKey and RowKey (together form unique ID).
Create Entity
entity = {
"PartitionKey": "sales",
"RowKey": "order-001",
"product": "Widget",
"quantity": 5,
"price": 9.99,
"shipped": False
}
# Create (fails if exists)
table_client.create_entity(entity=entity)
# Upsert explicitly replaces; omitted mode defaults can merge instead.
from azure.data.tables import UpdateMode
table_client.upsert_entity(entity=entity, mode=UpdateMode.REPLACE)Get Entity
# Get by key (fastest)
entity = table_client.get_entity(
partition_key="sales",
row_key="order-001"
)
print(f"Product: {entity['product']}")Update Entity
# Replace entire entity
entity["quantity"] = 10
table_client.update_entity(entity=entity, mode="replace")
# Merge (update specific fields only)
update = {
"PartitionKey": "sales",
"RowKey": "order-001",
"shipped": True
}
table_client.update_entity(entity=update, mode="merge")Delete Entity
table_client.delete_entity(
partition_key="sales",
row_key="order-001"
)Query Entities
Query Within Partition
# Query by partition (efficient)
entities = table_client.query_entities(
query_filter="PartitionKey eq 'sales'"
)
for entity in entities:
print(entity["RowKey"]) # Do not dump property payloadsQuery with Filters
# Filter by properties
entities = table_client.query_entities(
query_filter="PartitionKey eq 'sales' and quantity gt 3"
)
# With parameters (safer)
entities = table_client.query_entities(
query_filter="PartitionKey eq @pk and price lt @max_price",
parameters={"pk": "sales", "max_price": 50.0}
)Select Specific Properties
entities = table_client.query_entities(
query_filter="PartitionKey eq 'sales'",
select=["RowKey", "product", "price"]
)List All Entities
# List all (cross-partition - use sparingly)
for entity in table_client.list_entities():
print(entity["RowKey"]) # Do not dump property payloadsBatch Operations
from azure.data.tables import TableTransactionError
# Batch operations (same partition only!)
operations = [
("create", {"PartitionKey": "batch", "RowKey": "1", "data": "first"}),
("create", {"PartitionKey": "batch", "RowKey": "2", "data": "second"}),
("upsert", {"PartitionKey": "batch", "RowKey": "3", "data": "third"}),
]
try:
table_client.submit_transaction(operations)
except TableTransactionError as e:
print(f"Transaction failed: {e}")Async Client
from azure.data.tables.aio import TableServiceClient, TableClient
from azure.identity.aio import DefaultAzureCredential
async def table_operations():
credential = DefaultAzureCredential()
async with TableClient(
endpoint="https://<account>.table.core.windows.net",
table_name="mytable",
credential=credential
) as client:
# Create
await client.create_entity(entity={
"PartitionKey": "async",
"RowKey": "1",
"data": "test"
})
# Query
async for entity in client.query_entities("PartitionKey eq 'async'"):
print(entity["RowKey"]) # Do not dump property payloads
import asyncio
asyncio.run(table_operations())Data Types
| Python Type | Table Storage Type |
|-------------|-------------------|
| str | String |
| int | Int64 |
| float | Double |
| bool | Boolean |
| datetime | DateTime |
| bytes | Binary |
| UUID | Guid |
Best Practices
1. Design partition keys for query patterns and even distribution
2. Query within partitions whenever possible (cross-partition is expensive)
3. Use batch operations for multiple entities in same partition
4. Choose upsert mode deliberately; idempotence also depends on business effects and concurrency
5. Use parameterized queries to prevent injection
6. Keep entities small — max 1MB per entity
7. Use async client for high-throughput scenarios
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- azure-devops – Thiết lập Azure Pipelines cho CI/CD, cấu hình pipeline build và release, quản lý dự án…
- azure-eventgrid-dotnet – SDK Azure Event Grid cho .NET. Thư viện client để xuất bản và tiêu thụ sự kiện với Azure…
- azure-eventgrid-java – Xây dựng ứng dụng hướng sự kiện bằng SDK Azure Event Grid cho Java. Dùng khi xuất bản sự…
- azure-eventgrid-py – SDK Azure Event Grid cho Python. Dùng để xuất bản sự kiện, xử lý CloudEvents và kiến…
- azure-eventhub-dotnet – SDK Azure Event Hubs cho .NET.
- azure-eventhub-py – SDK Azure Event Hubs cho Python để xử lý streaming. Dùng cho nhập sự kiện thông lượng…
- azure-eventhub-ts – Xử lý streaming sự kiện thông lượng cao và nhập dữ liệu thời gian thực.
- azure-functions – Các mẫu chuyên sâu cho phát triển Azure Functions, bao gồm mô hình isolated worker, điều…