Dragon
Dragon

Reputation: 455

How to create empty folder in azure blob storage

How to create empty folder in azure blob storage just like empty folder in tool "Azure Explorer"

Upvotes: 9

Views: 25135

Answers (4)

Danil Gaponov
Danil Gaponov

Reputation: 1441

Uploading an empty file in the directory you want to create, and then deleting it worked for me.

Upvotes: -1

Robert Chen
Robert Chen

Reputation: 5355

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/)

Upvotes: 3

conner.xyz
conner.xyz

Reputation: 7275

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://[email protected]/sub-dir-name

Followed by
hdfs dfs -mv wasb://[email protected]/file-name wasb://[email protected]/sub-dir-name/file-name

Upvotes: 0

Gaurav Mantri
Gaurav Mantri

Reputation: 136186

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.

Upvotes: 18

Related Questions