0

I have a Python script that loads files into a folder hierarchy in an Azure storage container/blob storage. The folder hierarchy structure is High-level-folder_name/Year/Month/Day/filename.json. For example : data/Scanner/2022/07/15/scanner23_30_45_21.json

New folders are added to the hierarchy, based on the current date. My code works, but for some reason a folder with a link to the top of the container hierarchy is also created at each level of the folder structure. See image below

enter image description here My code is below. Any ideas on what is causing the links to upper level of the hierarchy would be appreciated.

*I have a feeling this issue is linked to the Blob service being based on a flat storage scheme (rather than hierarchical scheme). Link here 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)
Steve
  • 475
  • 4
  • 12
  • 25

1 Answers1

1

when creating a folder hierarchy in blob storage it is the default underlined structure of azure blob storage

enter image description here

Azure made available this UI design that links helps to move one upper level of folder it analysis the previous path and move advances to the subsequent path. which we can't change or alter the view as default one.

Imran
  • 3,875
  • 2
  • 3
  • 12