Azure Storage Docs

Table Storage Entities

This document provides a detailed explanation of entities within Azure Table Storage, covering their structure, properties, and best practices.

What is an Entity?

In Azure Table Storage, an entity is the fundamental unit of data. It's similar to a row in a relational database, but with a more flexible schema. Each entity is stored in a table and is identified by a unique PartitionKey and RowKey.

Entity Structure

Every entity in Azure Table Storage has the following mandatory properties:

In addition to the mandatory properties, an entity can contain up to 252 custom properties. These properties can be of various data types, including:

Entity Limits

Be aware of the following limits when working with entities:

Working with Entities

You can perform various operations on entities using the Azure SDKs or REST API:

Example: Creating an Entity

Here's a conceptual example of creating an entity representing a user profile. In a real-world scenario, you would use an Azure SDK (e.g., .NET, Python, Java).


// Conceptual Example (using pseudocode)
let userEntity = {
    PartitionKey: "users",
    RowKey: "user123",
    Email: "john.doe@example.com",
    DisplayName: "John Doe",
    RegistrationDate: new Date("2023-10-27T10:00:00Z"),
    IsActive: true,
    LoginCount: 42
};

// Call an Azure SDK function to insert this entity into a table
// insertEntity("userTable", userEntity);
            

Entity Querying Considerations

When querying entities, leverage the PartitionKey and RowKey for efficient retrieval:

Note: Property names are case-sensitive. Ensure consistency in naming conventions.

Data Types and Conversions

Azure Table Storage stores property values as primitive data types. When using the SDKs, you'll typically work with native language types which are then converted appropriately.

Supported Primitive Data Types

.NET Type JSON Type Description
string String Textual data.
sbyte, byte, short, ushort, int, uint, long, ulong Number Integer values.
float, double, decimal Number Floating-point numbers.
bool Boolean true or false.
DateTime String (ISO 8601 format) Date and time values.
Guid String Globally unique identifiers.
byte[] String (Base64 encoded) Binary data.
Tip: For complex data structures, consider serializing them into a string (e.g., JSON) or a byte array before storing them as a single property.

Next Steps

Now that you understand Azure Table Storage entities, you can explore how to query them efficiently or learn more about performance considerations.