Azure Table Storage vs CosmosDB with Python
Asked Answered
R

3

7

I am trying to access Azure Table Storage via python.

Following an old walkthrough here: https://learn.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-python#install-the-azure-storage-sdk-for-python

but the Python SDK it references for Azure Tables specifically (https://github.com/Azure/azure-storage-python) has been moved/deprecated in favor of Azure Cosmos DB SDK.

In the deprecation note, they say to use this SDK: https://github.com/Azure/azure-cosmosdb-python

In the documentation for that SDK, they refer you to https://azure.microsoft.com/en-us/develop/python/

In the Table Storage and link on that page, it refers you back to the first link (!!)

============

1) All I want to do is query traditional Azure Table Storage (NOT CosmosDB) with a Python SDK

2) Ideally, that Python SDK also includes the encryption/decryption capability for Azure Tables.

What am I missing / does that python SDK still exist anywhere?

Note: I see https://github.com/Azure/azure-cosmosdb-python/tree/master/azure-cosmosdb-table but this SDK seems to require a CosmosDB deployment -- it can't connect to traditional AzureTables. Is my understanding incorrect?

Thanks for any help you can offer.

Raynell answered 21/1, 2018 at 22:49 Comment(2)
Hi,any updates now?Isolate
thanks for the answer you provided! Helpful to know - though I was looking for the explanation if it was completely absorbed/interchangeable with the cosmos python sdk, which Laurent's answer makes clearRaynell
J
9

The Azure CosmosDB Table SDK IS Azure Storage Tables SDK. Re-branding is part of some re-org inside Microsoft, but this is the same code and same endpoint, same everything.

Storage SDK was one big client, it was split into Table/Queue/Blog/Files packages, in order to give ownership of Table to CosmosDB team.

https://learn.microsoft.com/en-us/azure/cosmos-db/table-support

The new Azure Cosmos DB Python SDK is the only SDK that supports Azure Table storage in Python. This SDK connects with both Azure Table storage and Azure Cosmos DB Table API.

You can also compare the code, you'll see:

(I work at MS in the Azure SDK for Python team)

Jala answered 23/1, 2018 at 2:53 Comment(5)
Hi, I'm still trying to find the actual documentation for the SDK (i.e. methods/syntax, expected behavior, inputs/outputs). It doesn't seem to exist anywhere. The CosmosDB Python SDK link leads to some github website with no real info: azure.github.io/azure-documentdb-python/api/pydocumentdb.html Any clues?Raynell
This should be there learn.microsoft.com/python/api/overview/azure/cosmosdb but it isn't indeed. Let me send an email to the doc team.Jala
Does this mean that Table Storage is going to be deprecated in favor of Cosmo DB option for Table Storage ?Assignable
Table Storage is not annunced deprecated at the moment, but most of the documentation will encourage you to pass to CosmosDB: learn.microsoft.com/en-us/azure/cosmos-db/…Jala
Or learn.microsoft.com/en-us/azure/cosmos-db/…Jala
D
3

Azure Table Storage has a new python library in preview release that is available for installation via pip. To install use the following pip command

pip install azure-data-tables

This SDK is able to target either a Tables or Cosmos endpoint (albeit there are known issues with Cosmos).

For your use case of querying an Azure Table Storage account, there's two query methods.

Querying a single table:

from azure.data.tables import TableClient

table_client = TableClient.from_connection_string(conn_str, table_name="myTableName")
query_filter = "RowKey eq 'row_key_5'"
for entity in table_client.query_entities(filter=query_filter):
    print(entity)

Querying a storage account for tables:

from azure.data.tables import TableServiceClient

table_service_client = TableServiceClient.from_connection_string(conn_str, table_name="myTableName")
query_filter = "TableName eq 'myTable'"
for table in table_service_client .query_entities(filter=query_filter):
    print(table.table_name)

For more samples on the library check out the samples hosted on the Azure GitHub Repository.

(FYI I work at Microsoft on the Azure SDK for Python team)

Deemphasize answered 4/1, 2021 at 20:2 Comment(0)
I
0

Indeed , Azure hides part of the Table Storage SDK guided links facilitate the promotion of the Cosmos DB Table API. As you mentioned in your answer, the Azure Storage SDK is now incorporated into the Cosmos menu.

However , I found the old Azure Table Storage Python SDK from previous version in the repo.

enter image description here

You could refer to the above link even if it's no longer updated.

By the way, you could see the benefits by moving to Azure Cosmos Table API from Azure Table Storage from this link.

Hope it helps you.

Isolate answered 22/1, 2018 at 3:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.