[英]Azure C# Function: How to read from Table Storage
I am trying to read from Azure Table Storage using a C# function, and am following the guidelines listed in this answer ( How to get all rows in Azure table Storage in C#? ). I am trying to read from Azure Table Storage using a C# function, and am following the guidelines listed in this answer ( How to get all rows in Azure table Storage in C#? ). However, at the last line of my code, I get the following error:
但是,在我的代码的最后一行,我收到以下错误:
CloudTable does not contain a definition for ExecuteQuery
CloudTable 不包含 ExecuteQuery 的定义
Below is my code:下面是我的代码:
var creds = new StorageCredentials(accountName, accountKey);
var account = new CloudStorageAccount(creds, useHttps: true);
// Retrieve the role assignments table
var client = account.CreateCloudTableClient();
var table = client.GetTableReference("RoleAssignmentTable");
var entities = table.ExecuteQuery(new TableQuery<RoleAssignment>()).ToList();
I am using Azure Functions v2.0
and .NET Core SDK 3.1.302
我正在使用
Azure Functions v2.0
和.NET Core SDK 3.1.302
The package( Microsoft.WindowsAzure.Storage.Table
) you use is too old, Microsoft is mainly support this package( Microsoft.Azure.Cosmos.Table
) now.您使用的包(
Microsoft.WindowsAzure.Storage.Table
)太旧,微软现在主要支持这个包( Microsoft.Azure.Cosmos.Table
)。 you can obtain this package from this link , and i have tested it for you, using this package can achieve the effect you want.你可以从这个链接获得这个package,我已经为你测试过了,使用这个package可以达到你想要的效果。
You do not need to change your code, you only need to pay attention to use the one I recommend when importing the package, and it like this:不需要改代码,只需要注意导入package时我推荐的那个,如下:
using Microsoft.Azure.Cosmos.Table;
You can also use this method to query your results:您也可以使用此方法查询您的结果:
var queryResult = table.ExecuteQuerySegmentedAsync(new TableQuery<myEntity>(), Token).Result.ToList();
But it returns a maximum of 1000 entities in a single call.但它在一次调用中最多返回 1000 个实体。 If there're more than 1000 entities available in your table, it returns a continuation token which can be used to fetch next set of entities.
如果您的表中有超过 1000 个可用实体,它会返回一个可用于获取下一组实体的延续令牌。
For more details, you can refer to this official document .更详细的可以参考这个官方文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.