CloudTableClient not compatible with .NET Core?

Viewed 1335

I have a .NET Core 2.2 Web Application and I'm trying to talk to a my Azure Table Storage resource. What I have so far:

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();
        }
    }
}

However when I hover over CreateCloudTableClient I see Reference to type CloudStorageAccount claims it is defined in Microsoft.Azure.Storage.Common but it could not be found.

How do I perform basic Table CRUD from within a .NET Core 2.2 web app?

2 Answers

You seem to have mixed up old and newer assemblies.

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

Either work with the newer NuGet references to Microsoft.Azure.CosmosDB.*, or with the older Microsoft.WindowsAzure.Storage assemblies, but not both.

For example:

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

These are .NET Framework libraries:

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

Use this .NET Core library:

using Microsoft.Azure.Cosmos.Table;
Related