简体   繁体   English

如何使用 C# 连接到 Azure 存储表

[英]How to connect to Azure Storage Table with C#

I would like connect to existing Azure Storage Table and read (filtered) data from it.我想连接到现有的 Azure 存储表并从中读取(过滤)数据。 I found some examples, but everyone used deprecated WindowsAzure.Storage namespace.我找到了一些示例,但每个人都使用了已弃用的 WindowsAzure.Storage 命名空间。 I can not found any solution for Azure.Storage.Common or some else from current Microsoft namespaces.我在当前 Microsoft 命名空间中找不到 Azure.Storage.Common 或其他一些解决方案。 There is many examples for Azure.Storage.Blobs, but i need solution for Table Storage service. Azure.Storage.Blobs 有很多示例,但我需要表存储服务的解决方案。 Thanks much...非常感谢...

Another suggested solution is to use the Microsoft.Azure.Cosmos.Table package.另一个建议的解决方案是使用Microsoft.Azure.Cosmos.Table package。 As stated in the description:如描述中所述:

When used with Azure Table Storage service, this library offers similar APIs and functionalities as WindowsAzure.Storage 8.7.0.当与 Azure 表存储服务一起使用时,此库提供与 WindowsAzure.Storage 8.7.0 类似的 API 和功能。

Its full documentation can be found here .它的完整文档可以在这里找到。

A code sample that helps you get a connection to a table and do actions in the below:一个代码示例,可帮助您连接到表并执行以下操作:

 private async Task<CloudTable> GetTable() {
        var storageAccount = CloudStorageAccount.Parse(StorageConnectionString);
        var tableClient = storageAccount.CreateCloudTableClient(new TableClientConfiguration());
        var table = tableClient.GetTableReference(TableName);
        await table.CreateIfNotExistsAsync();
        return table;
    }

The Azure.Data.Tables package is the current generation update to the Tables client library and is currently in beta. Azure.Data.Tables package 是 Tables 客户端库的当前更新版本,目前处于测试阶段。 Samples can be found in the Azure SDK repository in the Tables sample area.示例可以在表格示例区域的Azure SDK 存储库中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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