Storage Table Operations

This document details the common operations you can perform on Azure Storage Tables, including creating, querying, updating, and deleting entities and tables.

Core Operations

Creating a Table

Tables are created using the Table REST API's "Create Table" operation. This is an idempotent operation; if a table with the same name already exists, it will return a success status code (e.g., 204 No Content).

POST /Tables HTTP/1.1
Content-Type: application/json
Accept: application/json
DataServiceVersion: 3.0;NetTracer
x-ms-version: 2019-02-02

{
    "TableName": "MyNewTable"
}

Querying Entities

You can query entities from a table using the Table REST API. OData syntax is used to filter, select, and order results. Filtering by PartitionKey and RowKey is highly recommended for performance.

Example: Retrieving all entities from a table:

GET /MyNewTable()?$format=application/json;odata=fullmetadata HTTP/1.1
Accept: application/json
x-ms-version: 2019-02-02

Example: Filtering entities by PartitionKey:

GET /MyNewTable()?$filter=PartitionKey eq 'PartitionA'&$format=application/json;odata=fullmetadata HTTP/1.1
Accept: application/json
x-ms-version: 2019-02-02

Inserting an Entity

To insert a new entity, use the "Insert Entity" operation. You can choose between several feed formats, with JSON being the most common.

POST /MyNewTable(PartitionKey='PartitionA',RowKey='Row1')?$format=application/json;odata=fullmetadata HTTP/1.1
Content-Type: application/json
Accept: application/json
x-ms-version: 2019-02-02

{
    "Timestamp": "2023-10-27T10:30:00Z",
    "Description": "Sample entity data",
    "Value": 123,
    "IsActive": true
}

Updating an Entity

Entities can be updated using the "Update Entity" operation. Similar to insertion, you have options for replacing or merging.

Example: Replacing an entity:

PUT /MyNewTable(PartitionKey='PartitionA',RowKey='Row1')?$format=application/json;odata=fullmetadata HTTP/1.1
Content-Type: application/json
Accept: application/json
If-Match: * 
x-ms-version: 2019-02-02

{
    "Timestamp": "2023-10-27T10:30:00Z",
    "Description": "Updated entity data",
    "Value": 456,
    "IsActive": false
}

Deleting an Entity

To delete an entity, use the "Delete Entity" operation, specifying the PartitionKey and RowKey of the entity to be removed.

DELETE /MyNewTable(PartitionKey='PartitionA',RowKey='Row1') HTTP/1.1
Accept: application/json
x-ms-version: 2019-02-02

Deleting a Table

You can delete an entire table using the "Delete Table" operation. This action is irreversible.

DELETE /MyNewTable HTTP/1.1
Accept: application/json
x-ms-version: 2019-02-02

Batch Operations

Azure Storage Tables supports batching operations to improve efficiency by reducing the number of round trips to the service. You can combine multiple entity operations (insert, update, delete) within a single batch request.

Batch requests are sent to the account's root endpoint. The content type must be multipart/mixed and adheres to OData batch formatting rules.

Key considerations for batch operations:

Table Metadata Operations

Beyond entity operations, you can also manage table metadata.

Refer to the Table REST API documentation for comprehensive details on request formats, headers, and response codes for all operations.