How to create empty folder in azure blob storage just like empty folder in tool "Azure Explorer"
4 Answers
Technically speaking, you can't have an empty folder in Azure Blob Storage as blob storage has a 2 level hierarchy - blob container and blob. You essentially create an illusion of a folder by prefixing the file name with the folder name you like e.g. assuming you want a style sheet (say site.css) in say css
folder, you name the stylesheet file as css/site.css
.
What some of the tools do is in order to create an empty folder, they create a zero byte blob and prefix it with the name of the folder and then don't show that zero byte blob. If you want, you can do that.

- 128,066
- 12
- 206
- 241
-
thank you so much, i also try to create a zero byte blob, but i do not know how to hide this file – Dragon Nov 03 '14 at 20:33
-
So you can't really hide the blob. What you do is when you list blobs, you remove the blob from the blobs list and show other blobs. However please keep in mind that folks will be able to see this blob if they are trying to access your blob storage through some other tool. – Gaurav Mantri Nov 04 '14 at 05:09
-
1Good answer. Some tools use $$$.$$$ as a convention for the the "blank blob" . See http://stackoverflow.com/questions/10445830/why-does-a-blob-with-filename-appear-in-azure-directory-listing – Murray Foxcroft Feb 22 '17 at 13:44
Here's one way to do it with Linux.
az storage blob upload --container-name <container name> --name <folder name> -f /dev/null --account-name <storage account name>
- the file name ends with a trailing slash (e.g.
myfolder/
) - the CLI expects a file, so just upload nothing (i.e.
/dev/null/
)

- 5,179
- 3
- 34
- 21
Gaurav's point is good to understand.
Though in practice, when using hdfs
cli in bash, I've found you can't just rename the file (using mv
as you normally would) if the sub-directory you're attempting to 'create' doesn't already exist.
You can however use
hdfs dfs -mkdir -p wasb://container-name@account-name.blob.core.windows.net/sub-dir-name
Followed by
hdfs dfs -mv wasb://container-name@account-name.blob.core.windows.net/file-name wasb://container-name@account-name.blob.core.windows.net/sub-dir-name/file-name

- 6,273
- 8
- 39
- 65
If you have An ADLS Gen2 it is possible. For further details, please refer to the following URL Creating a hierarchical container directory using PowerShell in Azure ADLS Gen2 storage account

- 17
- 1
-
2A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](/help/deleted-answers) – Sabito stands with Ukraine Nov 22 '20 at 07:47
-