I am trying to list all azure tables and then iterate over them to delete each table. Here first I get list of all cloud tables and then trying to iterate over all cloud tables. But it gives me exception on lopping over it.
Code is as follows
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
CloudTableClient tableClient;
IEnumerable<CloudTable> tables = tableClient.ListTables();
foreach (CloudTable table in tables)
table.DeleteIfExists();
At for loop is breaks and does not allows to iterate. Below is the exception details.
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase
1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.TableQuery
1.ExecuteQuerySegmented(TableContinuationToken token, CloudTableClient client, String tableName, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.TableQuery1.<>c__DisplayClass7.<Execute>b__6(IContinuationToken continuationToken) at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__0
1.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at CleanStorageAccount.Program.Main(String[] args) in c:\Users\vargup\Documents\Visual Studio 2013\Projects\CleanStorageAccount\CleanStorageAccount\Program.cs:line 34 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
tableClient
? – crthompson