Table Service REST API
This documentation provides a comprehensive reference to the Azure Table service REST API. The Table service is a NoSQL key-attribute store that allows you to store large amounts of unstructured and semi-structured data. The Table service is accessible via anonymous HTTP or HTTPS requests. Developers can query the Table service using the REST API directly, or through Azure SDK libraries available in various languages.
Table Service Operations
The Table service exposes the following operations:
Service Operations
These operations manage the Table service itself and are performed against the storage account endpoint.
| Operation | HTTP Method | Description | Resource |
|---|---|---|---|
| Get Service Stats | GET | Retrieves the statistics of the Table service. | / |
| Get Service Properties | GET | Retrieves the properties of the Table service. | / |
| Set Service Properties | PUT | Sets the properties of the Table service. | / |
Table Operations
These operations manage tables within the Table service.
| Operation | HTTP Method | Description | Resource |
|---|---|---|---|
| Query Tables | GET | Queries a collection of tables. | /$metadata/Tables |
| Create Table | POST | Creates a new table. | /$metadata/Tables |
| Delete Table | DELETE | Deletes a table. | /Tables(' |
| Query Entities in Table | GET | Queries entities within a specific table. | /'table-name' |
| Insert Entity | POST | Inserts a single entity into a table. | /'table-name' |
| Batch Operation | POST | Performs a batch of operations. | /$batch |
Common Query Parameters
When querying tables or entities, you can use the following common query parameters:
$filter: Filters the results to return only entities that satisfy the OData filter expression.$select: Specifies the properties to return for each entity.$top: Specifies the maximum number of entities to return.$orderby: Specifies the order in which entities are returned.
Authentication and Authorization
All requests to the Azure Table service must be authenticated. The primary methods are:
- Shared Key Authentication: Using the storage account name and account key.
- Shared Access Signatures (SAS): Delegated access to specific resources with defined permissions and expiry times.
- Azure Active Directory (Azure AD): Using Azure AD identities for authentication and authorization.
For detailed information on authentication methods, refer to the Azure Storage authentication overview.
Entity Structure
An entity in the Table service is a collection of name-value pairs, similar to a row in a database table. Each entity has the following required properties:
PartitionKey: Identifies the partition that the entity belongs to. Entities with the samePartitionKeyare stored in the same partition.RowKey: Uniquely identifies an entity within a partition.Timestamp: Automatically managed by the Table service, representing the last modification time of the entity.
In addition to these required properties, an entity can contain up to 62 custom properties, each with a name and a supported data type.
Supported Data Types
The Azure Table service supports the following data types:
Edm.BinaryEdm.BooleanEdm.ByteEdm.DateTimeEdm.DoubleEdm.GuidEdm.Int32Edm.Int64Edm.String
Example: Querying Entities
The following example shows how to query entities from a table named "Products" that have a PartitionKey of "Electronics" and select only the Name and Price properties.
GET https://<your-storage-account-name>.table.core.windows.net/Products?$filter=PartitionKey eq 'Electronics'&$select=Name,Price HTTP/1.1
Authorization: SharedKey :
Date: Tue, 29 Sep 2023 17:48:41 GMT
Accept: application/json;odata=fullmetadata
Example Response (JSON):
{
"value": [
{
"PartitionKey": "Electronics",
"RowKey": "001",
"Timestamp": "2023-09-29T17:48:41.1234567Z",
"Name": "Laptop",
"Price": 1200.50
},
{
"PartitionKey": "Electronics",
"RowKey": "002",
"Timestamp": "2023-09-29T17:48:41.7890123Z",
"Name": "Smartphone",
"Price": 799.99
}
]
}
Best Practices
- Design your
PartitionKeyto distribute data evenly across partitions for better scalability. - Use batch operations to improve performance when inserting or updating multiple entities.
- Carefully consider the data types for your properties to optimize storage and query performance.
Get Service Stats
Retrieves the statistics of the Table service. This operation is useful for monitoring the health and performance of your storage account.
HTTP Method: GET
Resource URI: /
GET https://<your-storage-account-name>.table.core.windows.net/ HTTP/1.1
Authorization: SharedKey :
Date: Tue, 29 Sep 2023 17:50:00 GMT
Create Table
Creates a new table in the Table service. The table name must be unique within the storage account and follow specific naming conventions (alphanumeric characters and hyphens, cannot start with a number).
HTTP Method: POST
Resource URI: /Tables
Request Body:
{
"TableName": "MyNewTable"
}