在 C# .NET Core 中使用 Azure TableStorage - Nuget 包 WindowsAzure.Storage 替代方案

Using Azure TableStorage in C# .NET Core - Nuget Package WindowsAzure.Storage Alternative

我正在编写一个新应用程序来将日志存储在 Azure 的 Table 存储中。

这是我的存储对象的样子:

public class ErrorLog : TableEntity
{
    public static ErrorLog Create(DateTime dateTime, int httpStatusCode, string message)
        => new ErrorLog
        {
            PartitionKey = GetPartitionKey(dateTime),
            RowKey = GetRowKey(dateTime),
            HttpStatusCode = httpStatusCode,
            Message = message,
        };

    public int HttpStatusCode { get; set; }

    public string Message { get; set; }

    public static string GetPartitionKey(DateTime dateTime) 
        => dateTime.ToString("yyyy_MM_dd_HH");

    public static string GetRowKey(DateTime dateTime)
        => dateTime.ToString("mm_ss");
}

但是,我试图找到新的 NuGet 包来代替“WindowsAzure.Storage”(已被弃用),但无济于事。

因为 WindowsAzure.Storage has been deprecated. Package Microsoft.Azure.CosmosDB.Table is in maintenance mode and it will be deprecated soon. You should use Microsoft.Azure.Cosmos.Table 库也可用于访问 Azure 存储表。

Microsoft.Azure.Cosmos.Table 是一个用于 Azure 表的新包。 https://www.nuget.org/packages/Microsoft.Azure.Cosmos.Table