Azure Storage Tables REST API
The Azure Storage Tables service is a NoSQL key-attribute store that accepts authenticated calls using HTTP or HTTPS. You can query and store data in tables using the Tables REST API. Data in the Tables service is represented as a collection of entities. Each entity is a collection of properties. Each property is a name-value pair.
Overview
The Tables service provides a schema-less NoSQL store for storing large amounts of structured non-relational data. You can access data in the Tables service from any client that can send an HTTP or HTTPS request. You can use the Tables REST API directly, or you can use one of the Azure Storage client libraries for .NET, Java, Python, or Node.js, which wrap the REST API.
The Tables service consists of the following components:
- Storage Account: Your Azure Storage account is the top-level namespace for all Azure Storage data objects.
- Tables: A table is a collection of entities. A table is a NoSQL data structure that has no schema.
- Entities: An entity is a set of properties. An entity is analogous to a row in a database.
- Properties: A property is a name-value pair. An entity can have at most 252 properties, plus the PartitionKey and RowKey properties.
Key Concepts
Understanding the following concepts is crucial for working with the Tables service:
- PartitionKey and RowKey: Together, these two properties form the unique identifier for an entity. The PartitionKey is used to group entities within a table, and the RowKey uniquely identifies an entity within a partition. This combination is known as the entity's OData ID.
- Indexing: The Tables service automatically indexes the PartitionKey and RowKey properties. You can also create custom indexes on other properties to improve query performance.
- Transactions: The Tables service supports entity group transactions, which allow you to perform multiple operations on entities within the same partition as a single atomic operation.
- Querying: You can query entities in a table using OData syntax. The Tables service supports filtering, sorting, and selecting specific properties.
REST API Operations
The following table lists the common operations supported by the Tables REST API. All requests must be authenticated. For details on authentication, please refer to the Azure Storage authentication documentation.
Tables Operations
| Operation | HTTP Method and URI | Description |
|---|---|---|
| Create Table |
POST/{accountName}/Tables
|
Creates a new table in the specified storage account. |
| Query Tables |
GET/{accountName}/Tables
|
Queries for tables within the specified storage account. |
| Delete Table |
DELETE/{accountName}/Tables('{tableName}')
|
Deletes a table and all of its data. |
Entities Operations
| Operation | HTTP Method and URI | Description |
|---|---|---|
| Insert Entity |
POST/{accountName}/{tableName}
|
Inserts a new entity into a table. |
| Query Entities |
GET/{accountName}/{tableName}
|
Queries for entities within a table. Supports OData filtering and projection. |
| Get Entity |
GET/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Retrieves a specific entity by its PartitionKey and RowKey. |
| Update Entity |
PUT/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Updates an existing entity using a full overwrite. Requires If-Match header for concurrency control. |
| Merge Entity |
MERGE/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Updates an existing entity by merging provided properties. Requires If-Match header for concurrency control. |
| Delete Entity |
DELETE/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Deletes a specific entity. Requires If-Match header for concurrency control. |
| Insert or Replace Entity |
PUT/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Inserts an entity if it doesn't exist, or replaces it if it does. |
| Insert or Merge Entity |
MERGE/{accountName}/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')
|
Inserts an entity if it doesn't exist, or merges it if it does. |
Entity Group Transactions
Entity group transactions allow you to perform operations on multiple entities within the same partition atomically.
| Operation | HTTP Method and URI | Description |
|---|---|---|
| Batch Operation |
POST/{accountName}
Request Body: multipart/mixed |
Executes a batch of operations on entities within the same partition. |
Common Query Parameters
| Parameter | Description |
|---|---|
$filter |
Specifies the filter expression for OData queries. Supports comparison operators, logical operators, and functions. |
$select |
Specifies the comma-separated list of properties to return. |
$top |
Specifies the maximum number of entities to return. |
$orderby |
Specifies the comma-separated list of properties to sort by, with optional ascending (asc) or descending (desc) order. |
Accept |
Indicates the desired response format. For Tables REST API, typically application/json;odata=minimalmetadata or application/json;odata=fullmetadata. |
Content-Type |
Indicates the format of the request body. For Tables REST API, typically application/json;odata=minimalmetadata. |
If-Match |
Used for optimistic concurrency control when updating or deleting entities. Can be an ETag value or *. |
Request and Response Examples
For detailed examples of HTTP requests and responses for each operation, please refer to the official Azure Storage documentation.