使用CloudTable绑定到v2 Azure Functions中的表存储 [英] Binding to Table Storage in v2 Azure Functions using CloudTable
问题描述
因此,根据此问题在GitHub 上,支持CloudTable
可用于绑定到表存储,但是未提供任何特定信息或示例.
在一个最小的工作示例中,v2 Azure Function的表存储绑定看起来如何(例如,从表存储中读取表的所有行)?
非常感谢您的帮助!
So according to this issue on GitHub, support for IQueryable
was dropped for v2 Azure Functions. This is also reflected in the official docs. That doc also mentions that CloudTable
could be used to bind to Table storage, however no specific information or examples are provided.
In a minimal working example, how would a Table Storage binding for a v2 Azure Function look like (for, say, reading all rows of a table from table storage)?
Any help is highly appreciated!
推荐答案
应该简单
[FunctionName("TestFunction")]
public static async Task Run(
[QueueTrigger("test-queue")] string message,
[Table("testTable")] CloudTable testTable)
{
var querySegment = testTable.ExecuteQuerySegmentedAsync(new TableQuery<ResultEntity>(), null);
foreach (ResultEntity item in querySegment.Result)
{
// Access table storage items here
}
}
可在此处获得完整的工作示例.
A full working example is available here.
这篇关于使用CloudTable绑定到v2 Azure Functions中的表存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!