Table Storage

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

20

 

  • 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.

1.png

Add the Nuget Package for Windows Azure Storage

2.png

With this package the following Class reference will be added to your project.

3.png

Then add Nuget for Windows Azure Configuration Manager, for reading storage connection string from app.config

4.png

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.

5.png

Add the storage account name and keys in the Config as showed below:

6.png

Create a Custom Entity to store in the Table. The custom Entity should inherit from Table Entity as showed below:

Student.png

Next Create a class named ‘TableStoreExample’ and add a constructor as showed below:

21.pngNext Create the Table named ‘table1’ in case if not exists as showed below

22

Next we can add a row into the ‘table1’ as an Entity.

23.png

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.

24.png

Finally we can use Azure Storage Explorer to see the Table we have created.

25.png

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.

26.png

28.png

Output is showed below:

27.png

Delete Row

Next is to get Delete the row that we have created. please look on to the below code:

29.png

Delete Table

We will see how we can delete the Table that we have created.

31.png

Summary of how we have called all these methods:

32.png

Hope you have got a basic level of information about Azure Table Storage.

Happy Programming.

%d bloggers like this: