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

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

问题描述

所以根据GitHub上的this issue,支持IQueryable 已针对 v2 Azure Functions 删除.这也反映在 官方文档.该文档还提到 CloudTable 可用于绑定到表存储,但未提供具体信息或示例.在一个最小的工作示例中,v2 Azure 函数的表存储绑定是什么样的(例如,从表存储中读取表的所有行)?非常感谢任何帮助!

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天全站免登陆