Tips, tricks and all the info about Microsoft Visual Studio 2008

Windows Azure Table Storage - Getting Started - Part 2

, posted: 5-Mar-2009 09:00

In Part 1, we went through the basics of Windows Azure Table Storage. In Part 2, we will be creating a simple application to demonstrate the Windows Azure Table Storage.

The sample application we are going to create is a small guestbook app which will allow your site visitors to enter some information.

Creating the Project

Open Visual Studio 2008 and create a Web Cloud Service project.

Updating Service Definition

The first step to do is to update the service definition and service configuration files to include the storage account. Edit your service definition file found in the Guestbook project and enter these settings


This specifies your Windows Azure account name


The shared key used to authenticate requests made against your Windows Azure account


The base URI of the table storage service

Updating Service Configuration

After setting the properties in our service definition, we need to set the values of those properties in our service configuration file found in the Guestbook project





All the values reflect your local development storage and nothing in the cloud. The development storage supports only the above fixed account and is same for everyone.

We should be able to test our azure application locally in the local development storage before deploying it to the cloud.  Testing your application locally will also help you to debug your applications.

Creating  the Table Schema

Defining the table schema is as easy as creating classes. The idea here is to create a class, where the class name corresponds to the table name and the properties correspond to the table properties. The local development storage environment uses ADO.NET to create tables in the local environment, whereas this is not needed when we host our application in the cloud.

Creating these classes are made simple by using the StorageClient library provided in the Windows Azure SDK

You can add the StorageClient project to our Guestbook solution or just reference the library.

Below is our class which represents the Guestbook table:

As you can see in the above screenshot, our class GuestDataModel inherits TableStorageEntity. This TableStorageEntity class is available in the StorageClient library and defines some of the properties such as partition key and row key that is required for each entity in the table.

The GuestDataModel consists of three properties:

1) Message
2) Name
3) Url

And our simple constructor where we initialize the partition key and row key:

As the local storage uses ADO.NET we are going  to create class GuestDataServiceContext which inherits from  TableStorageDataServiceContext from the StorageClient library. The TableStorageDataServiceContext represents the runtime context of our ADO.NET service.

Now having the data model and the data context in place, its very easy to query our storage and perform the usual insert, delete operations

We create a GuestDataSource which is going to help interact with the data context and insert, delete and get all the GuestDataModel entities

As you can see, it's pretty straight forward. Below are insert and delete methods:

Creating our Tables

We saw how to insert, delete and get all our entities from the table using a simple data source, but where are we actually creating the table?

We are going to create the table on the first request to the website which can be done by adding the appropriate code into the global application class.
Executing this guestbook sample

Executing this guestbook sample is just as same as executing a normal application! Hit F5 and Visual Studio 2008 will take care of everything - from starting the local development storage, creating the tables and debugging the application.

Below is a screenshot of our guestbook app:

Deploying Guestbook to the Cloud

To deploy this sample in the cloud, you should have a Windows Azure storage account. For more information on deploying a service on Windows Azure, visit here.

I have already deployed this application to the cloud. So, if you are interested to try it out, please visit

You can download the Guestbook sample below:

Visual Studio 2008 simplifies building Windows Azure applications using the Windows Azure tools for Visual Studio. It also allows us to debug Windows Azure applications.

Download Visual Studio 2008 90 day trial
For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the Microsoft Visual Studio webpage.

About the Author
Chaks is currently working for Intergen as a Software Developer. Chaks works extensively in Microsoft Platform. His knowledge covers various Microsoft Technologies like WCF, SharePoint, Windows Azure, ASP.NET. Chaks also writes for Neowin, one of the Microsoft featured communities. You can contact Chaks via his blog - Chaks' Corner.

Other related posts:
The New Zealand ALM Conference 2011 (Application Life Cycle Management)
Writing your own Html Helpers for the ASP.NET MVC Framework
Automating Visual Studio 2008

Comment by Anna, on 14-Mar-2009 01:44

Hi Chaks! I'd like very much to talk to you about a proposed partnership. Can you send me your email? Thank you very much. I'm waiting for your reply! Regards, Anna.

Comment by hajimu, on 23-Jul-2009 06:20

I have tried your program. Many thanks.
I could run without debugging, but fail with debugging in time out.
PLS advise me the cause of it. 

About the Visual Studio 2008 Blog

In the years since the hugely successful release of Visual Studio 2005, Microsoft has used developer feedback from all over the world to introduce over 250 new features in the 2008 release.

This sponsored blog will bring Visual Studio 2008 tips and tricks from well known developers in the Australian and New Zealand tech community directly to you.

Make sure you bookmark this blog or subscribe to our RSS feed.

Other blog posts

The New Zealand ALM Conference...
Writing your own Html Helpers ...
Automating Visual Studio 2008...
Windows Azure Table Storage - ...
XML and XSLT in Visual Studio ...
Introduction to New SQL Server...
Using the Visual Studio 2008 P...
Getting started with Windows A...
Why consider sitting for an MC...
Unit testing .Net Compact Fram...

Some recent comments

Praveen M on Visual Studio 2008 support for building SilverLigh: I installed SILVERLIGHT TOOLS for VS2008 at my work. I am able to do silverlight...

zefo on Unit testing with Visual Studio 2008: Just minor recommendation: better use *.png for the screenshots. Jpeg is more su...

gil ziny on Unit testing with Visual Studio 2008: When I associate the unit test with TFS testing policy, if fails during check-in...

lynette on Visual Studio 2008 JavaScript Debugging: i have enable in IE the ability to debug scripts. if i go to my section in my c...

Junkie on Why consider sitting for an MCTS or MCP Certificat: The way you presented the case for certification has been completely different f...

Brian Link on Unit testing with Visual Studio 2008: You seem to be incorrect in one of your opening remarks - it seems that web.conf...

Dipanwaya on Unit testing .Net Compact Framework applications w: Steps Behind the Test in the VS 2008? How to test a module in the VS 2008 Envir...

Ricardo on Visual Studio 2008 support for building SilverLigh: Yes! Found the solution myself :) Reset the environment of Visual Web Developer...

Ricardo on Visual Studio 2008 support for building SilverLigh: Have the same problem after installing Visual Web Developer 2008 SP1 and Silverl...

kjward on Automating Visual Studio 2008: thanks lots for all the great info. i'm sure the answer to my question is in th...


The Visual Studio 2008 blog is sponsored by Microsoft NZ. The blog posts are the authors' genuine accounts of their experiences with Visual Studio 2008 and are not influenced or filtered by Microsoft NZ in any way.