Azure Table storage is a service that stores structured data in the cloud. Table storage is a key/value store with a schemaless design.
Azure tables are ideal for storing structured, non-relational data. Common uses of the Table service include:
- Storing datasets that don’t require complex joins, foreign keys, or stored procedures and can be denormalized for fast access
- Quickly querying data using a clustered index
- Accessing data using the OData protocol and LINQ queries with WCF Data Service .NET Libraries
- Table: A table is a collection of entities. Tables don’t enforce a schema on entities, which means a single table can contain entities that have different sets of properties. The number of tables that a storage account can contain is limited only by the storage account capacity limit.
- Entity: An entity is a set of properties, similar to a database row. An entity can be up to 1MB in size.
- Properties: A property is a name-value pair. Each entity can include up to 252 properties to store data. Each entity also has 3 system properties that specify a partition key, a row key, and a timestamp. Entities with the same partition key can be queried more quickly, and inserted/updated in atomic operations. An entity’s row key is its unique identifier within a partition.
How do we do it?
After creating the Storage Access as mentioned in my previous article (refer blob storage); you can open visual studio with a new Project.
Add the Nuget Package for Windows Azure Storage
With this package the following Class reference will be added to your project.
Then add Nuget for Windows Azure Configuration Manager, for reading storage connection string from app.config
Now add Storage connection string in the App.Config file. To get the Stirage connection string Open Portal and find the Storage Account you have created eg: ‘abrahamstorageaccount‘ and get the keys for it.
Add the storage account name and keys in the Config as showed below:
Create a Custom Entity to store in the Table. The custom Entity should inherit from Table Entity as showed below:
Next Create a class named ‘TableStoreExample’ and add a constructor as showed below:
Next Create the Table named ‘table1’ in case if not exists as showed below
Next we can add a row into the ‘table1’ as an Entity.
In this Table Name, Age, Sex are the properties of the Entity or columns in the table. Similarly we can add 256 columns in an Entity.
Next we will initiate the class and see how it is working.
Finally we can use Azure Storage Explorer to see the Table we have created.
Delete a Row from Table
To read a row from the table use the following code: We can read using the Partition Key and Row Key as a unique identifier.
Output is showed below:
Next is to get Delete the row that we have created. please look on to the below code:
We will see how we can delete the Table that we have created.
Summary of how we have called all these methods:
Hope you have got a basic level of information about Azure Table Storage.