I use the below azcopy command in powershell script to filter and transfer json files from one Azure blob to another.
azcopy copy "$sourceContainerUri" "$destContainerUri" --include-pattern '.json' --recursive=true
There are 10000 blobs that the azcopy will read to filter the json files and transfer to destination with the blob structure. The problem is some of the blobs do not have any json files and the azcopy skips it as it considers them as empty.
my requirement is to copy those empty blobs as well . Pls note these blobs are not really empty as they have other types of files like .csv, .txt. I would like to achieve this is the same script as I am using this in a scheduled pipeline job. Thanks.
Copying empty folders from Azure blob
In Azure blob storage, we cannot store empty folders because, folders are represented as virtual directories, which are created by including a forward slash (/) in the blob name. For example, if you create a blob named folder1/folder2/file.txt
, it will create a virtual directory named folder1
and a subdirectory named folder2
within it. However, the blob folder1/folder2
itself does not contain any data.
As an example, if I delete the file in the folder it will delete and there were no other folders with the prefix folder1/folder2.
Portal:
Portal:
So you cannot able to copy only folders in Azure blob storage. If you need to store only folders you can use Azure datalake gen2
storage accounts.
Reference:
c# - List EMPTY directories in Windows Azure Blob storage container - Stack Overflow by Emily Gerner