azure - 如何在.NET Core项目中使用WindowsAzure.Storage.Table?

标签 azure asp.net-core .net-core azure-storage

我安装了 Windows Azure Storage 8.1.4我在 Visual Studio 2017 中新创建的 ASP.NET Core Web 项目中的 NuGet 包。

实际上我尝试使用它,例如 Microsoft docmentation建议(table.ExecuteQuery(query)),但只有“异步”方法:

enter image description here

代码:

public class HelloWorldController : Controller
{
    public string ReadTables() {
        CloudStorageAccount storage = CloudStorageAccount.Parse(connStr.MyTablesConnStr);
        CloudTableClient tableClient = storage.CreateCloudTableClient();
        CloudTable table = tableClient.GetTableReference("themes");

        StringBuilder response = new StringBuilder("Here is your test Table:");
        var query = new TableQuery<ProjectThemeEntity>() {
            SelectColumns = new List<string> {"RowKey", "Description" }
        };

        // No way to do it in the controller action ?! ----------
        var items=await table.ExecuteQuerySegmentedAsync<ProjectThemeEntity>(query, null);

        foreach (ProjectThemeEntity item in items) {
            response.AppendLine($"Key: {item.RowKey}; Value: {item.Description}");
        }

        return response.ToString();
    }

我发现过去也有类似的问题,比如this one ...

知道如何解决这个问题吗?

最佳答案

@Serge .NET Core 尚未包含 API 的同步实现。因此您可以改用 ExecuteQuerySegmentedAsync。检查this

您关注的文章也没有说它适用于 .NET Core。

enter image description here

关于azure - 如何在.NET Core项目中使用WindowsAzure.Storage.Table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45041294/

相关文章:

html - 新 Ghost 博客上的链接仅在 Chrome 中不起作用的问题

asp.net-mvc - 从 MVC3 迁移到 MVC4 和 Azure 1.7 - 为什么 iisexpress.exe 现在出现在日志文件中

node.js - Nodejs Azure 部署失败 : ENOENT: no such file or directory, 统计 '/home/site/wwwroot/node_modules/.bin/semver'

c# - 在 IFrame 中的 ASP.NET Core 2.0 应用程序中使用 session 状态

c# - dnxcore50 可以引用针对 .net4.5 编译的 nuget 包吗

c# - 如何在 .net 核心中使用 TimeZoneInfo.GetAdjustmentRules()?

c# - 通过 NuGet 为 .net 核心项目提供代码分析规则集

azure - Azure AD 是否与 GCP/GKE 集成以允许 SSO?

asp.net-core - 如何获取类库中的连接字符串?

security - JWT token - 中间人攻击