Azure Table 存储与 CosmosDB Python

Azure Table Storage vs CosmosDB with Python

我正在尝试通过 python 访问 Azure Table 存储。

按照此处的旧演练: https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-python#install-the-azure-storage-sdk-for-python

但是它为 Azure Tables 特别是 (https://github.com/Azure/azure-storage-python) 引用的 Python SDK 得到了 moved/deprecated 的支持Azure Cosmos DB SDK。

在弃用说明中,他们说要使用此 SDK: https://github.com/Azure/azure-cosmosdb-python

在该 SDK 的文档中,他们将您引向 https://azure.microsoft.com/en-us/develop/python/

在该页面的 Table 存储和 link 中,它会将您引回到第一个 link (!!)

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

1) 我想要做的就是使用 Python SDK

查询 traditional Azure Table 存储(不是 CosmosDB)

2) 理想情况下,Python SDK 还包括用于 Azure Tables 的 encryption/decryption 功能。

我错过了什么/python SDK 是否仍然存在?

注: 我看到了 https://github.com/Azure/azure-cosmosdb-python/tree/master/azure-cosmosdb-table 但此 SDK 似乎需要 CosmosDB 部署——它无法连接到传统的 AzureTables。我的理解有误吗?

感谢您提供的任何帮助。

确实,Azure 隐藏了部分 Table Storage SDK 引导 link 方便 Cosmos DB Table API 的推广。正如您在回答中提到的,Azure 存储 SDK 现已合并到 Cosmos 菜单中。

但是,我在回购中找到了来自 previous version 的旧 Azure Table 存储 Python SDK。

以上link即使不再更新也可以参考

顺便说一句,您可以看到从这个 link.

的 Azure Table 存储迁移到 Azure Cosmos Table API 的好处

希望对你有帮助。

Azure CosmosDB Table SDK IS Azure 存储 Tables SDK。品牌重塑是 Microsoft 内部某些重组的一部分,但这是相同的代码和相同的端点,一切都相同。

Storage SDK 是一个大客户,它被分成 Table/Queue/Blog/Files 个包,以便将 Table 的所有权交给 CosmosDB 团队。

https://docs.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.

你也可以对比一下代码,你会看到:

(我在 MS 工作,负责 Python 团队的 Azure SDK)

Azure Table Storage 有一个 new python library 预览版,可通过 pip 安装。要安装,请使用以下 pip 命令

pip install azure-data-tables

此 SDK 能够针对 Tables 或 Cosmos 端点(尽管 Cosmos 有 known issues)。

对于查询 Azure Table 存储帐户的用例,有两种查询方法。

查询单个 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)

查询存储帐户 table 秒:

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)

有关库中的更多示例,请查看 Azure GitHub Repository 上托管的示例。

(仅供参考,我在 Microsoft 为 Python 团队开发 Azure SDK)