使用CloudTable绑定到v2 Azure Functions中的表存储 [英] Binding to Table Storage in v2 Azure Functions using CloudTable

查看:76
本文介绍了使用CloudTable绑定到v2 Azure Functions中的表存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,根据此问题在GitHub 上,支持已针对v2 Azure Functions删除.这也反映在官方文档.该文档还提到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆