How to connect to Azure Storage Table with C#

Viewed 3466

I would like connect to existing Azure Storage Table and read (filtered) data from it. I found some examples, but everyone used deprecated WindowsAzure.Storage namespace. I can not found any solution for Azure.Storage.Common or some else from current Microsoft namespaces. There is many examples for Azure.Storage.Blobs, but i need solution for Table Storage service. Thanks much ...

2 Answers

Another suggested solution is to use the 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.

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;
    }
Related