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.
Then create a storage account as below,
Make sure to put your own connection string to azure storage to parse. Next you need to create instance of table client
Once tableclient is created you can list all the tables by making call to ListTables() method.
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(); }
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,
In this way you can list all the tables name from Windows Azure Storage Account. I hope this post is useful. Thanks for reading
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.
Leave a Reply