Fetching name of all tables in Windows Azure Storage

To list all the table name from Windows Azure storage account, you need to call ListTable() function of CloudTableClient class. To start with first you need to add below namespaces.

image

Then create a storage account as below,

clip_image001

Make sure to put your own connection string to azure storage to parse. Next you need to create instance of table client

clip_image003

Once tableclient is created you can list all the tables by making call to ListTables() method.

clip_image004

For your reference full source code to fetch all the tables name from Windows Azure Storage account is given below,


using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;
namespace ConsoleClient
{
class Program
{
static void Main(string[] args)
{

string connectionString = "DefaultEndpointsProtocol=https;AccountName=abc;AccountKey=jsjdsfjgdsfj09===";
var TablesName = GetTablesNameForAzureSubscription(connectionString);
foreach (var r in TablesName)
{
Console.WriteLine(r.ToString());
}
Console.ReadKey(true);
}

private static List<string> GetTablesNameForAzureSubscription(string connectionString)
{
CloudStorageAccount account =CloudStorageAccount
.Parse(connectionString);

CloudTableClient tableClient = new CloudTableClient
(account.TableEndpoint.ToString(),
account.Credentials);

var result = tableClient.ListTables();

return result.ToList();
}

&nbsp;

On running of above code you should be getting the table name listed for the account mentioned in connection string. In this case I have three tables listed to the account as below,

clip_image001[6]

In this way you can list all the tables name from Windows Azure Storage Account. I hope this post is useful. Thanks for reading  Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

2 responses to “Fetching name of all tables in Windows Azure Storage”

  1. […] Fetching name of all tables in Windows Azure Storage […]

  2. […] find anything in the Windows Azure HOWTO. I only found the official REST API documentation and this blog which explain what I want to do, but it's not in […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com