1

Possible Duplicate:
How to create a sub container in azure storage location

I want to migrate an application to work under Windows Azure. In the application, I am upload files to a certain folder on the server. This folder contains other nested folders and these nested folders contains files.

below are some examples:

  • CompanyName/CV/CV1.docx
  • CompanyName/Pics/Pic1.jpeg
  • CompanyName/Pics/Pic2.jpeg

Now in Windows Azure, I want to use BLOB storage in order save my files. The problem in BLOB is that I have container and I cannot create nested containers to organize my files.

Can anybody help me to find the best solution in order to save my files.

Community
  • 1
  • 1
Ghyath Serhal
  • 7,466
  • 6
  • 44
  • 60

3 Answers3

2

You can use azure blob storage to store files

The only option you will need to manipulate the blob container in this way is to use the folowing option :

new BlobRequestOptions { UseFlatBlobListing = true }


you will be able to list the files using this sentence :

yourContainer.ListBlobs(new BlobRequestOptions { UseFlatBlobListing = true });

they will appear like that :

  • CompanyName/CV/CV1.docx
  • CompanyName/Pics/Pic1.jpeg
  • CompanyName/Pics/Pic2.jpeg


you will be able to retrieve you file like this :

yourBlob.DownloadToFile("CompanyName/Pics/Pic2.jpeg", new BlobRequestOptions { UseFlatBlobListing = true });


you can find more information about this option here : Msdn Definition of the UseFlatBlobListing Property

Voosten
  • 21
  • 4
1

You could use Windows Azure Drives, it works like your standard harddisk drive, ie. "X:" but actually stores the files in the Azure Blob. This way you can work with your files like you have always done in your legacy application.

From this article

A Windows Azure drive acts as a local NTFS volume that is mounted on the server’s file system and that is accessible to code running in a role. The data written to a Windows Azure drive is stored in a page blob defined within the Windows Azure Blob service, and cached on the local file system. Because data written to the drive is stored in a page blob, the data is maintained even if the role instance is recycled. For this reason, a Windows Azure drive can be used to run an application that must maintain state, such as a third-party database application.

Dene
  • 578
  • 5
  • 9
  • 1
    Azure Drives may only have one writer. If the application is such that there are multiple instances of Web or Worker role accepting file uploads, they cannot write to the same Azure Drive. – David Makogon Jan 06 '12 at 12:04
1

You can use Cloud Drive, which give you the ability to mount a NTFS virtual drive in your application.

But I think the best solution is to use BLOB storiage delimiter. You cannot create sub containers but you can add the blobs with delimiter. For example Container_Name/books/book1.doc Container_Name/books/book2.doc Container_Name/images/img1.jpg Then you can list the blobs by specify the delimiters.

Shaun Xu
  • 4,476
  • 2
  • 27
  • 41