Q78: How to create a table using a simple C# Console application?
Open Visual Studio and create a C# Console application from the standard template.
By default, the created project will not have a reference to the storage library, but we can add that easily using the NuGet package manager. Right-click on the project and select 'Manage NuGet Packages' from the context menu. This will load up the Package Manager UI. Select the 'Online' tab from the Package Manager dialog, and search for 'Azure Storage'. Select the Windows Azure Storage package and click 'Install'.
After adding references of the Windows Azure Storage Client Library, you need to add the following namespaces. Open the program.cs file and add the following statements to the top of the file.
static void Main(string args)
//Add the following to the Main method:
CloudStorageAccount account = CloudStorageAccount.Parse(
CloudTableClient client = account.CreateCloudTableClient();
CloudTable table = client.GetTableReference(“items”);
catch (Exception ex)
Console.WriteLine(“Done... press a key to end.”);
Explanation of code: Create an instance of CloudStorageAccount. The CloudStorageAccount object is the root object we use to access to any of the storage sub systems: Blobs, Queues and Tables.
The code creates a CloudTable object using the GetTableReference method of the CloudTableClient object. The statement table.CreateIfNotExists(), will make a call to the Table service REST API and, if a table named 'items' does not exist within the storage account it will be created. Remember that the Table service is a REST based API. We have created a table, and next, we will add entities to it.
See More Questions and Answers on - Azure Table Storage (cont..)