Azure Table Storage
Azure Table Storage is a NoSQL key-attribute store that accepts authenticated calls from HTTP or HTTPS. Table Storage is designed to store large amounts of structured, non-relational data. Its schema-less design allows you to adapt more easily to changes in your data requirements.
Key Concepts
Entities
An entity is a set of properties, similar to a row in a database table. Each entity can have a different set of properties. Entities are identified by two strings: the PartitionKey and the RowKey. Together, the PartitionKey and RowKey form the entity's unique key.
Properties
A property is a name-value pair within an entity. Property names are strings, and property values can be any of the following Azure Table Storage data types:
- Binary (
Edm.Binary
) - Boolean (
Edm.Boolean
) - DateTime (
Edm.DateTime
) - Double (
Edm.Double
) - Guid (
Edm.Guid
) - Int32 (
Edm.Int32
) - Int64 (
Edm.Int64
) - String (
Edm.String
)
PartitionKey and RowKey
Every entity must have a PartitionKey
and a RowKey
. These two properties together form the entity's unique identifier.
- PartitionKey: Entities with the same
PartitionKey
are co-located on the same storage node. This allows for efficient querying of entities within a partition. - RowKey: Within a partition, entities are sorted by their
RowKey
. This allows for fast retrieval of specific entities.
Operations
Table Storage supports common data operations:
- Create Entity: Add a new entity to a table.
- Query Entities: Retrieve entities based on various filter criteria.
- Update Entity: Modify existing entities.
- Delete Entity: Remove entities from a table.
Querying
Queries can be scoped to a specific partition or across all partitions. Using the PartitionKey
in your query significantly improves performance.
Example: Creating and Querying an Entity
Here's a conceptual example using a hypothetical SDK. The actual implementation will vary based on the SDK or REST API used.
// Assume 'tableClient' is an initialized Azure Table Storage client
// Define the entity
var entity = new Dictionary
{
{ "PartitionKey", "Users" },
{ "RowKey", "user123" },
{ "Email", "user.example@email.com" },
{ "Age", 30 },
{ "IsActive", true }
};
// Insert the entity
await tableClient.AddEntityAsync(entity);
// Query for the entity
var queryResult = await tableClient.GetEntityAsync("Users", "user123");
var retrievedEntity = queryResult.Value;
Console.WriteLine($"Retrieved Email: {retrievedEntity["Email"]}");
Console.WriteLine($"Retrieved Age: {retrievedEntity["Age"]}");
Pricing
Azure Table Storage pricing is based on the amount of data stored and the number of transactions performed. For detailed information, please refer to the official Azure Table Storage pricing page.
Table Storage Explorer (Simulated)
Enter details for a new user entity.
Entity Added: