【问题标题】:List all azure tables in a storage account列出存储帐户中的所有 Azure 表
【发布时间】:2014-05-02 15:42:19
【问题描述】:

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

代码如下

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

在 for 循环中是中断并且不允许迭代。以下是异常详情。

在 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Table.TableQuery1.ExecuteQuerySegmented(TableContinuationToken token, CloudTableClient 客户端, String tableName, TableRequestOptions requestOptions, OperationContext operationContext) 在 Microsoft.WindowsAzure.Storage.Table.TableQuery1.<>c__DisplayClass7.<Execute>b__6(IContinuationToken continuationToken) at Microsoft.WindowsAzure.Storage.Core.Util.CommonUtility.<LazyEnumerable>d__01.MoveNext() 在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() 在 c:\Users\vargup\Documents\Visual Studio 2013\Projects\CleanStorageAccount\CleanStorageAccount\Program.cs: 34 中的 CleanStorageAccount.Program.Main(String[] args) 在 System.AppDomain._nExecuteAssembly(RuntimeAssembly 程序集,字符串 [] 参数) 在 System.AppDomain.ExecuteAssembly(字符串 assemblyFile,证据 assemblySecurity,String [] args) 在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在 System.Threading.ThreadHelper.ThreadStart_Context(对象状态) 在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback 回调,对象状态,布尔值 preserveSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态,布尔值 preserveSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback 回调,对象状态) 在 System.Threading.ThreadHelper.ThreadStart()

【问题讨论】:

  • 你在哪里/如何定义tableClient?
  • 这看起来也不像一个完整的堆栈跟踪。
  • 添加了表客户端声明。是的,堆栈跟踪已完成。我知道了解决方案,我将我的 Microsoft.WindowsAzure.Storage.dll 从 2.1 更新到 3.1,它开始工作了。
  • 很高兴你能成功。在您的错误中没有实际的错误消息,这就是为什么我认为您遗漏了一些东西。

标签: azure azure-table-storage


【解决方案1】:

我将 Microsoft.WindowsAzure.Storage.dll 引用从 2.1 更新到 3.1 版本,并且相同的代码对我有用。

【讨论】:

    【解决方案2】:

    这很好用:

        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, '', '');
        }
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 2021-01-07
      • 2021-04-16
      • 1970-01-01
      • 2021-10-10
      • 2019-12-05
      • 2020-06-08
      • 2021-11-16
      • 1970-01-01
      相关资源
      最近更新 更多