CloudTableClient是否与.NET Core兼容?

3

我有一个.NET Core 2.2 Web应用程序,试图与我的Azure表存储资源进行通信。目前为止,我已经完成了以下工作:

using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.CosmosDB.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WebApplication1.Repositories
{
    public class AssetRepository
    {
        public AssetRepository()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse("cstring");
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
        }
    }
}

然而,当我悬停在CreateCloudTableClient上时,我看到对类型CloudStorageAccount的引用声称它在Microsoft.Azure.Storage.Common中定义,但找不到该类型。

如何在.NET Core 2.2 Web应用程序内执行基本的Table CRUD操作?


你需要发布有关连接字符串和配置的更多详细信息。 - Llazar
2个回答

7

您似乎混淆了旧的和较新的程序集。

using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.CosmosDB.Table;

请使用较新的Microsoft.Azure.CosmosDB.* NuGet引用或旧版的Microsoft.WindowsAzure.Storage组件,但不能同时使用两者。

例如:

using Microsoft.Azure.CosmosDB.Table;   // replaces Microsoft.WindowsAzure.Storage.Table
using Microsoft.Azure.Storage;          // replaces Microsoft.WindowsAzure.Storage

0

这些是 .NET Framework 库:

using Microsoft.WindowsAzure.Storage; //legacy
using Microsoft.Azure.CosmosDB.Table;

使用这个 .NET Core 库:

using Microsoft.Azure.Cosmos.Table;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接