python - 在 Blob 存储中创建文件夹层次结构时生成意外链接

标签 python azure azure-blob-storage python-3.9

我有一个 Python 脚本,可将文件加载到 Azure 存储容器/blob 存储中的文件夹层次结构中。文件夹层次结构为 High-level-folder_name/Year/Month/Day/filename.json。例如:data/Scanner/2022/07/15/scanner23_30_45_21.json

新文件夹将根据当前日期添加到层次结构中。我的代码有效,但由于某种原因,还在文件夹结构的每个级别创建了一个带有容器层次结构顶部链接的文件夹。见下图

enter image description here 我的代码如下。任何有关导致链接到层次结构上层的原因的想法将不胜感激。

*我感觉这个问题与基于平面存储方案(而不是分层方案)的 Blob 服务有关。链接在这里With help of Python, how can I create dynamic subfolder under Azure Blobstorage?

import os
from pathlib import Path
from datetime import datetime
import json
from azure.storage.blob import BlobClient

#file name
datetime_string = datetime.utcnow().strftime("%Y_%m_%d-%I_%M_%S_%p")
#folders that the files foes in Year -> months -Filename.json
year_utc = datetime.utcnow().strftime("%Y")
month_utc = datetime.utcnow().strftime("%m")
filename_prefix =f"Scanner/{year_utc}/{month_utc}/{datetime_string}.json"
data = json.dumps("test_content_of_file",indent = 4)
blob = BlobClient.from_connection_string(conn_str="Connectionstringetc",
                                    container_name="data", blob_name= filename_prefix)                                         
blob.upload_blob(data, overwrite=False)

最佳答案

在 Blob 存储中创建文件夹层次结构时它是 Azure Blob 存储的默认带下划线的结构

enter image description here

Azure 提供了此 UI 设计该链接有助于移动上一层文件夹它分析上一个路径并将进度移动到下一个路径。我们无法更改或更改默认 View 。

关于python - 在 Blob 存储中创建文件夹层次结构时生成意外链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72988814/

相关文章:

python - 整数加一和三元运算符

python - 成对相似度/相似度矩阵计算优化

python - paramiko,不是在与 ssh-agent 交谈。织物中的相同行为

azure - 客户端: Accessing Windows Azure Drive?

python - AzureBlob上传错误:The specified blob already exists

python - 我的分割序列代码有什么问题

c# - .Net 接口(interface),返回类型已知,但参数类型/数量未知

azure - GetBlobReference 和 GetBlobReferenceFromServer 有什么区别?

Azure Blob 触发器未触发

c# - 尝试将 Azure 文件复制到 Azure Blob 时如何使用 Azure SAS