【问题标题】:Read the latest file from azure blob python从 azure blob python 读取最新文件
【发布时间】:2020-09-22 06:13:57
【问题描述】:

我在一个 Azure blob 中有多个文件。我只想阅读/下载最新的文件。 我怎样才能通过python做到这一点。

注意:我正在使用 azure ML 数据存储连接到 blob 所在的容器。

【问题讨论】:

    标签: azure-blob-storage azureml


    【解决方案1】:

    为了执行基于 blob 属性的逻辑,您必须与 blob 容器进行交互。

    确保您拥有azure-storage-blob 库:

    conda install azure-storage-blob 
    

    (或pip install,如果这是您的偏好)

    在 Azure 门户中,导航到您的存储帐户,在左侧栏中选择 Access Keys,然后复制您的 Connection String 之一。另外,要知道保存 Blob 的 Blob 容器的名称。

    连接并做逻辑:

    from azure.storage.blob import ContainerClient
    
    container = ContainerClient.from_connection_string(conn_str={your_connection_string}, container_name = {your_container_name})
    for blob in container.list_blobs():
        print(f'{blob.name} : {blob.last_modified}')
    

    【讨论】:

      猜你喜欢
      • 2021-10-05
      • 2021-06-01
      • 2018-07-08
      • 2016-07-15
      • 2012-06-16
      • 1970-01-01
      • 2021-10-18
      • 1970-01-01
      • 2021-04-01
      相关资源
      最近更新 更多