Skip to main content

Azure Table Storage - Create


Back - Azure > Azure Storage

The Requirement
Assuming that we have a front end solution and we are going to create a lightweight CMS for its landing page, The landing page has a splash carousel banner that switch between banner automatically, Our mission is to populate the banner list to the front end hooked with Javascript framework and css that is already downloaded to the client browser / Apps. Our CMS team require some sort like a mechanism to publish new banner or delete old banner or take a specific banner online during festive season or offline when it is over. We decided to use Azure Table Storage as our data store and currently developing the data access strategy.

Consideration
This code base is proposed for the intention for understanding its usage, for production/release we might need to tweak it to meet the company policy, best practice and industry standards.

The Model
We are using an interface to describe our concrete data model entity
The Table Entity
In order to use Azure Table Storage the data model that we wish to insert into the data store must be inherited with a TableEntity class that decorated from ITableEntity. Below are the sample snippet of our table Entity

The Data Store Information Needed
To use an Azure Table Data Storage, we need 2 key information regarding our data store.
1. The Azure Storage Name - In this Example we name it as OurCRMStorage
2. The Azure Storage Table Access Key - Each Azure Storage will have their own key, we will be able to find it through the Azure Portal

Establish A Connection To The Data Store
Before we started to inject anything to the data store, we need to establish a connection to the data store using the 2 key information above. This can be done using the snippet code below.

Create A Table Client
Since we are the client who wanted to access the data store, we need to instantiate a TableClient class to perform all our CRUD actions against the data store. We also need to notify which table that we are referring to and create one if we believe that it might not exist yet.below are the code snippet to perform the algorithm.

Final Step - Perform The CRUD
Finally we may use all the instantiated class above to inject the insert.
Assuming that 'Data' is an object that is a type of SplashBannerAzure class we may add it into the InsertOrReplace method since it is derived from the TableEntity class. The key here is ct.Execute(b); this is when the connection pipe is open and the transaction is done to inject to the Azure Storage Table.
Conclusion
From the article we may summarize in order to perform a CRUD-Add to Azure Storage table, we require some information on the Azure Storage Table details and we also need to instantiate some classes to perform the tasks before finally execute the data injection.

Back - Azure > Azure Storage

Published on : 5-May-2018
Ref no : DDN-WPUB-000013

About Author

My photo
Wan Mohd Adzha MCPD,MCSD,MCSE
I am passionate about technology and of course love Durians. Certified by Microsoft as MCP Since 2011. Blogging from Malaysia

Comments