列出存储帐户中的所有azure表



我试图列出所有azure表,然后迭代它们以删除每个表。这里我首先得到所有云表的列表,然后尝试遍历所有云表。但它给了我一个例外,跳过它。

代码如下

CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
CloudTableClient tableClient;
IEnumerable<CloudTable> tables = tableClient.ListTables();
foreach (CloudTable table in tables)
                table.DeleteIfExists();

At for循环中断,不允许迭代。以下是异常的详细信息。

在Microsoft.WindowsAzure.Storage.Core.Executor.Executor

。[T](StorageCommandBase 1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.TableQuery)。ExecuteQuerySegmented(tableccontinuationtoken token, CloudTableClient客户端,String tableName, TableRequestOptions requestOptions, OperationContext OperationContext)在Microsoft.WindowsAzure.Storage.Table.TableQuery 1.<>c__DisplayClass7.<Execute>b__6(IContinuationToken continuationToken) at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__0 . movenext ()2. System.Linq.Enumerable.WhereSelectEnumerableIterator"movenext ()在CleanStorageAccount.Program。Main(String[] args) in c:UsersvargupDocumentsVisual Studio 2013ProjectsCleanStorageAccountCleanStorageAccountProgram.cs:第34行在System.AppDomain。_nExecuteAssembly(运行时汇编程序集,字符串[]args)在System.AppDomain。ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly ()在System.Threading.ThreadHelper。ThreadStart_Context(对象状态)在System.Threading.ExecutionContext。RunInternal(ExecutionContext, ExecutionContext, ContextCallback, callback, Object state, Boolean, preserveSyncCtx)在System.Threading.ExecutionContext。运行(ExecutionContext ExecutionContext, ContextCallback, callback, Object state, Boolean, preserveSyncCtx)在System.Threading.ExecutionContext。运行(ExecutionContext, ExecutionContext, ContextCallback, callback, Object state)在System.Threading.ThreadHelper.ThreadStart ()

我将Microsoft.WindowsAzure.Storage.dll参考从2.1版本更新到3.1版本,相同的代码为我工作。

运行正常:

    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
        CloudConfigurationManager.GetSetting("StorageConnectionString"));
    CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
    var table = tableClient.ListTables();
    foreach (CloudTable t in table)
    {
        insertEntity(t.Name, boxNewPage.Text, '', '');
    }

相关内容

  • 没有找到相关文章

最新更新