How to create Folder(s)/Directory inside Blob Container

Hi All,
Ii wonder if there is any out of box functionality or solution that i can use to achieve the subject.
preferably not using AzCopy. the user case here would be that i have Container ABC and i would like to create the folders “Folder_A” and “Folder_B” under ABC , then uploading files to each folders.

Thanks in advance!

Hi @TheBestBirth,

You can use the About the Azure Activities Pack (uipath.com)
image

You will need to use the Create Blob Container

Azure will automatically create the folder structure
“Folder_A” and “Folder_B” under ABC

  • “ABC/Folder_A”
  • “ABC/Folder_B”

If you need to move a file then you can use

  • “ABC/Folder_A/File.txt”
  • “ABC/Folder_B/File.txt”

Thanks jeevith for your reply, Looks like i do not manage it get it to work, i thought it would do the trick but when i tired , i got an error due to Blob Container name. so that’s why i got confused and wonder if there could be another way!
do you have any example which you can share with me?

Hi @TheBestBirth,

Can you show us what is the error message you get? As I remember, the folder structure gets created automatically with the given string path.

Could be interesting to see what is the error message you get.

@jeevith Yep, here it is :slight_smile:
Create Blob Container: Invalid Blob Container Name XXXXXXX/test. Please check Naming and Referencing Containers, Blobs, and Metadata - Azure Storage | Microsoft Learn for more information

where XXXXXX is Blob Container
any idea what could be wrong here?

Did you pass the above as “XXXXXXX/test” also if you already have a container setup then the xxxxxx is case senstive.

well , this XXXXXX is not the actual name ( unfortunately i cannot share the actual one here ) and just for illusion purpose. the name is identical with what i have in Azure, and yes, it is pass to Create Blob Container.
i also check with get Containers list and use that one, no dice!

Sure, I understand I meant xxxxxx as a placeholder. You are following documentation with path or full file paths. The only thing to check is the real folder names are exact to the one you created in azure.

I wish I had access to test this myself. Have some issues with VPN so can’t help you with a .xaml file.

@jeevith
i have just made another container called abc and try to make a folder under it. same error
image

So the authentication to your resource went as planned but access to the blob fails.

Can you check with Get Blob Container just to check what it returns?

yep, the authentication works fine. get Blob Container works fine too.
not quite sure if Access to Blob fails since i can upload / Download a Blob to that Container.

Update: when i use Upload Blob from file with file path like abc/Folder_A/1.txt, if Folder_A does not exist in abc, it will be created automatically.
so that i may need to change my question to can i create empty folder under abc? and if so, how ? :smiley:

Ok, one step closer !

May be the UiPath azure package has a bug and does the parse the folderpath xxxxxx/Test as nested folders.

Could you try making the same using PowerShell azure module ? If PowerShell can create empty folders in a blob then we know that there is something fishy with Azure package in UiPath.

You can reuse the PowerShell code later with UiPath using invoke PowerShell activity so it’s time well invested :slight_smile:

I think you don’t/ cannot create empty folders in Azure blob storage.

think of the folder as an attribute of the file. It cannot exist without a file, so when you create the file with a specified path the path just exists

Hi @dave1,

The documentation link @TheBestBirth shared does say that one can create virtual hierarchy without a file.

The Blob service is based on a flat storage scheme, not a hierarchical scheme. However, you may specify a character or string delimiter within a blob name to create a virtual hierarchy. For example, the following list shows valid and unique blob names. Notice that a string can be valid as both a blob name and as a virtual directory name in the same container:

  • /a
  • /a.txt
  • /a/b
  • /a/b.txt
    You can take advantage of the delimiter character when enumerating blobs.