.NET Core 2在相当长的一段时间里都是一团糟!
我需要一件非常简单的事情-我需要使用Microsoft.Azure.CosmosDB.Table
软件包在 .NET Core 2.2 应用程序中使用表存储。好的,让我们这样做吧?
首先,让我们创建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 **
);
好!我们从这里去哪里? 请不要为我指出示例-它们不适用于.NET Core 2.2!
我们不要混用 Microsoft.Azure.Storage 和 Microsoft.WindowsAzure.Storage 软件包!
什么时候可以解决?如何创建CloudTableClient并使用CloudTable?
答案 0 :(得分:0)
我必须得出结论,无法在.NET Core 2.x项目中使用Azure表。不能降级到某些旧软件包或预览版本。
答案 1 :(得分:0)
这很好用:
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();