Friday, March 19, 2010

Windows Azure – How to Use Table Storage.

I am going to create a Windows Azure Application which uses Table Storage to store my TODO Lists or TASKS.  Windows Azure Table Storage is Semi Structured and Query able  Table Storage and its a collections of Entities. These Entity have Primary key and set of Pre defined property.

Windows Azure Table service has two key properties: PartitionKey and the RowKey. These properties together form the table's primary key and uniquely identify each entity in the table. Every entity in the Table service also has a Timestamp system property, which allows the service to keep track of when an entity was last modified. This Timestamp field is intended for system use and should not be accessed by the application.

Table service does not enforce any schema for tables, which makes it possible for two entities in the same table to have different sets of properties.

Steps to create Windows Azure Table Storage.

1) Create Entity Class which is derived from TableServiceEntity.

2) Create a DataContext class which is derived from TableServiceContext, which itself derives from DataServiceContext.

3) Create Windows Azure Table Storage from our Model ( That is our Entity Class).

4) Test it with Local Development Fabric.

5) Publish to windows Azure ( Need to have account ).

Start (Run) VS.NET as an Administrator  and create the  new Cloud service project.

image

Add ASP.NET Web Role. All Web Role needs IIS to run. so we are basically developing ASP.NET Web application .

image

Now add class Template to the project to create our Entity Schema. Which is going to be Model Structure for our Windows Azure Table Storage. This SreeniTodo class defines the PartititionKey, RowKey and TimeStamp system properties required by every entity stored in a Windows Azure table

image

Create Data Context

image

image

image

DataConnectionString: This is the connection string to the Window Azure account, through which we can programmatically access data storage and other functionalities in Windows Azure. This connection string can point to a Windows Azure Account in the cloud as well as local development fabric.

image

Create a User interface to input the Entity  property filed , for sample i am getting only  Work Title and Assigned by

image

image

Once tested in Local Environment now time to publish to Windows Azure. Right click on Project and click publish. logon to your windows azure account create new service and select  Package and Configuration file to deploy.

Now change the Azure storage settings as shown below.

We initially ran our application to point to our local Development Storage. Now we need to point our application to Windows Azure Account.

image

image

image

Next we will see how to use other window Azure Storages Blob and Q .

Nandri(Thanks)

SreenivasaRagavan.

1 comment:

Pravesh Singh said...

Your article are really awesome. Actually I was in search for some good articles on DML and DQL using Table Service in Windows Azure and finally I got one.
The most important is the simplicity which will be very helpful for the beginners. Check this links too it helped me lot in completing task....
http://www.mindstick.com/Articles/0c3ac0b4-4294-4443-897d-c9947533f006/?DML%20and%20DQL%20using%20Table%20Service%20in%20Windows%20Azure

http://msdn.microsoft.com/en-us/library/windowsazure/dd179463.aspx