简体   繁体   中英

How can I create a CloudTableClient in .NET Core 2.2 app?

This has been a mess for a big while with .NET Core 2!

I need A VERY simple thing - I need to use Table Storage in my .NET Core 2.2 app using Microsoft.Azure.CosmosDB.Table package. ok, let's do this, shall we?

First things first, let's create CloudTableClient :

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

…

CloudTableClient tableClient = new CloudTableClient(
  new Uri("[WHAT TO PUT IN HERE in case of Azure and Emulator???]"),
  new Microsoft.Azure.Storage.Auth.StorageCredentials() // => **THIS DOES NOT EVEN COMPILE! Auth is not a part of the package **
);

NICE! Where do we go from here? Please don't point me to examples - they're not for .NET Core 2.2!

And let's not mix Microsoft.Azure.Storage and Microsoft.WindowsAzure.Storage packages!

When is this going to be fixed? How to create CloudTableClient and use the CloudTable?

This works perfectly fine:

var tableName = "TestTempTable";
var storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=....;AccountKey=....;EndpointSuffix=core.windows.net";
var storageAccount = CloudStorageAccount.Parse(storageConnectionString);
var tableClient = storageAccount.CreateCloudTableClient(new TableClientConfiguration());
var table = tableClient.GetTableReference(tableName);
await table.CreateIfNotExistsAsync();

I have to conclude that there is no way of working with Azure Tables in .NET Core 2.x projects. Downgrading to some old packages or preview versions is not an option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM