DEV Community

catrina
catrina

Posted on • Originally published at catrina.me on

Azure Blob’s Ghost Folders?

This week I had to address a "upload image to blob" application that I had built in my development environment. It was working fine, but it needed to be configured to work in production.

My Setup

For the application overall, I used Azure Samples for Upload Image to Storage (built in .NET Core). In it, the configuration in appsettings.json looks like this:

      "AzureStorageConfig": {
        "AccountName": "",
        "AccountKey": "",
        "ImageContainer": "images",
        "ThumbnailContainer": "thumbnails"
    }
Enter fullscreen mode Exit fullscreen mode

The Account Name and AccountKey are easily found in Azure Portal. For container name, I used Azure Storage Explorer, just so I could get a full look at the container and its blobs.

The Problem

The problem was, in my development environment I was uploading DIRECTLY to container. In the example above, I was uploading to the “images” container. In my Production environment, though, my ImagesContainer had two folders:

  • images/small
  • images/large

I tried to change the “ImagesContainer”:”images” to:

  • “ImagesContainer”:”images/small”

and then

  • “ImagesContainer”:”images\small”

Still, I had no luck. Requested URI not found.

The Solution

The folders you see are not actual folders, consider them sort of part of the file name with a folder delimiter of \, meaning you add the folder name to the front of the file name.

For example, the correct answer in the configuration above is:

  • “ImagesContainer”:”images”

but, when I specify the file name in my code to upload, it would be:

  • “small\mypic.jpg”

This directs the file to the images container and then its own file name would direct it under what folder and file name to store it.

Azure Storage is a bit odd sometimes, with its hierarchy and case-sensitive behavior, but once you are aware, it is quite easy to accommodate.

Quick Tip

There is no leading “\” on that filename. It simply should be:

  • “small\mypic.jpg”

Top comments (0)