In my previous articles about Microsoft Azure Storage, I’ve discussed about Blob Storage in detail. As I explained, in first article of the series that Azure Storage has 4 types of Storage Blob, Table, Queue, and File Storage.
In this article, I’m going to explain about Table Storage in Azure. Table is simply structured data which can be accessed by ADO.NET Data Services. Azure Table Storage is non-relational, key value pair, storage system suitable for storing massive amounts of structured data. So Table can be useful for applications that must store large amounts of relational data and need additional structure for that data.
So the Table Storage stores structured data without schemas, it does not provide any way to represent relationship between the data.
So for the table, you must have a Storage Account. In Storage Account we have got the two separate tables and in those table we have got Entity and in Entities we have columns property. I’m going to develop same table storage structure through the Visual Studio 2015.

Let’s see how we can create Table Storage programmatically and how to save the data into that Table storage. I’m using Visual Studio 2015 and Azure Storage Account like previous article. Follow the same steps of previous article unless ready of Controller.
Step 1
Create Asp.net Web Project and a give a name to your project.
Step 2
Select MVC Template
Step 3
Right click on to Project and add on “Connected Services” to connect with your Azure Storage Account. (Follow Part-Three of the series article)
I hope your project is ready now. Right click on to controller’s folder to add a controller. Create a Method under your controller and parse the connection string to retrieve your account detail from key is in Web.Config file as it is previous article where we created a client of the table, here we returned client for table. Next create a CloudTable object that represents your table name. Create the table if it doesn't exist and take it into ViewBag for showing it in View result and table name as well as.
- public class TableStorageController : Controller
- {
- public ActionResult MyTableCreation()
- {
- CloudStorageAccount userstorageAccount = CloudStorageAccount.Parse
- (CloudConfigurationManager.GetSetting("mystoragecontainer002_AzureStorageConnectionString"));
- CloudTableClient myTableClient = userstorageAccount.CreateCloudTableClient();
- CloudTable cricketTable = myTableClient.GetTableReference("cricketers");
- ViewBag.CreateSuccess= cricketTable.CreateIfNotExists();
- ViewBag.YourTableName = cricketTable.Name;
- return View();
- }
- }
Add following namespaces into your Controller
- using Microsoft.Azure;
- using Microsoft.WindowsAzure.Storage;
- using Microsoft.WindowsAzure.Storage.Table;
If you face any problem then you can refer to this screenshot.

Table should definitely be created but I want to show the result of adding a View. Right click on your ActionResult method and add a View. Add the following snippet into view
- @{
- ViewBag.Title = "MyTableCreation";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- <h2>Table Created</h2>
- <h3>
- Hey This Table <b style="color:red"> "@ViewBag.YourTableName" </b>
- @(ViewBag.CreateSuccess == true ? "Has Been Successfully Created." : "Already Exist Into Your Storage Account.☻")
- </h3><br />

Open _Layout.chtml and add another Action Link as shown below.

Run your application now. You’ll see there is a "Create Table" link to create a table. Click on it.

The result is on your screen. The table has been created.

You can check it in Azure Portal.

When you try to upload again with same name. It will produce the following result.

Add an Entity to a Table
In this article, we will see how we can add an Entity and Batch of Entities in a Table. Create a Model class and define properties of entity.
Right click on Models folder and add a class CricketerEntity.cs.

I’ve a Cricketer Entity class that uses TableEntity which represents the base object type for a table entity in the Table Service. The class uses the cricketer’s first name and last name with row key and partition key respectively, with some other property.
- public class CricketerEntity: TableEntity
- {
- public CricketerEntity(string lastName, string firstName)
- {
- this.PartitionKey = lastName;
- this.RowKey = firstName;
- }
- public CricketerEntity() { }
- public string BatingStyle { get; set; }
- public string Rank { get; set; }
- public string Runs { get; set; }
- }











Join the conversation! Your thoughts help the community grow.