c# - 使用 C# 中的 v4 函数应用从 Azure 表存储获取包含所有数据集的完整表

标签 c# azure azure-functions .net-6.0 azure-table-storage

使用旧版本的 .NET 和 Azure Function Apps v2,可以使用(除其他外)TableContinuationToken 从 Azure 表存储表获取所有数据集: Get more than 1000 datasets from an Azure Table Storage

由于底层 Microsoft.Azure.Cosmos.Table 包已弃用:

基于 .NET 6 的 v4 Azure Function App 中从 Azure 表存储中的表获取所有数据集的新方法是什么?

最佳答案

我已在我的环境中重现了该问题,并且能够获取数据列表。

感谢 @Gaurav Mantri 的评论。

  1. 在 azure 中创建存储帐户和表。 enter image description here

我使用下面的代码并能够获取数据列表

private void tableInsert()
        {

            CloudStorageAccount storage_Account = CloudStorageAccount.Parse(storageAccount_connectionString);
            CloudTableClient tableClient = storage_Account.CreateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("table1");


            for (int ctr = 0; ctr < 1000; ctr++)
            {
                EmployeeEntity employeeEntity = new EmployeeEntity("Fname"+ctr, "LName"+ctr)
                {
                    Email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="54273b3931203c3d3a3314273b3931203c3d3a337a373b39" rel="noreferrer noopener nofollow">[email protected]</a>",
                    PhoneNumber = "123456789"

                };

                TableOperation insertOperation = TableOperation.Insert(employeeEntity);
                table.ExecuteAsync(insertOperation);
            }
           
        }

用于获取

 public async Task<List<TableEntity>> GetList()
        {
            
            CloudTable table = await GetTableAsync();
            
            TableQuery<TableEntity> query = new TableQuery<TableEntity>();
            List<TableEntity> results = new List<TableEntity>();
            TableContinuationToken continuationToken = null;
            do
            {
                TableQuerySegment<TableEntity> queryResults = await table.ExecuteQuerySegmentedAsync(query, continuationToken);
                continuationToken = queryResults.ContinuationToken;
                results.AddRange(queryResults.Results);
            } while (continuationToken != null);
            return results;
        }
        private async Task<CloudTable> GetTableAsync()
        {
            
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageAccount_connectionString);
            
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable table = tableClient.GetTableReference("table1");
            await table.CreateIfNotExistsAsync();
            return table;
        }

enter image description here

引用自Azure Tables client library for .NET

关于c# - 使用 C# 中的 v4 函数应用从 Azure 表存储获取包含所有数据集的完整表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75003574/

相关文章:

c# - 从集合类设置只读属性

c# - 从 Xamarin.Android 中的单击事件处理程序访问 CheckBox 属性

c# - 未找到 System.ComponentModel.DataAnnotations.Schema

python - 在 python 中将字节 block 流式传输到 csv 行

Azure 函数应用程序设置与 local.settings.json 中的值不一致

node.js - 使用 Azure NodeJS Functions 下载平均 50kB 的 100,000 个文件的最快方法是什么?

c# - 使用 DateTime 查看本周的预订

azure - 标准定价层的 Azure 服务总线命名空间中缺少主题部分

azure - (Azure CDN Premium Verizon) 规则引擎 : 301 Redirect all requests to azurewebsites.net 和 azureedge.net URL

Azure Functions 失败通知