none
Image doesn’t load consistently from Azure blob storage

    Question

  • I am having an erratic problem using Azure blob storage where my images do not load consistently. The problem is that sometimes when I load a web page, the browser will not show the image, but if I refresh it will load correctly.

    When the image doesn't load, the browser shows the default image placeholder. Here is an example:

    If you check the hyperlink for the image placeholder, you will see that it is the same as the when the image loads successfully.

    Sometimes the same image will fail to load for one link but load successfully for another link even in the same page and same page load. The only difference in the URL is the Shared Access Signature.

    Here is my code to build the URL with the shared signature

    // Get reference to blob (file) that is to be downloaded
    blob = blobContainer.GetBlobReference(blobURL.ToString());
    // Get shared access signature to download file from azure blob (valid upto "active duration" minutes) from now
    signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
    {
    SharedAccessStartTime = null,
    SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60), 
    Permissions = SharedAccessPermissions.Read
    });
    // Append signature query string to blob / file that is to be downloaded
    downloadURL = string.Format("{0}{1}", blob.Uri.AbsoluteUri, signature);

    This is the final HTML image link on the web page, i.e. if I show source on the web page in the browser:

    <img alt="Profile Picture" src="https://mystorageaccount2.blob.core.windows.net/abcdefg1-hi23-40b5-86de-a20b568f5626/1601/1234d664d1b74ce1aebf4403e5b74af7.jpg?se=2015-10-31T11%3A38%3A39Z&amp;sr=b&amp;sp=r&amp;sig=SaiUToJg%5Ab3zcdef8EeOq84urHf6HQqS%2BAFt1dEQMNI%3D">

    Has anyone else seen this problem? Any recommendations on what I might be doing wrong?


    Tim Archer



    • Edited by Xethnic Saturday, October 31, 2015 11:21 AM
    Saturday, October 31, 2015 11:17 AM

Answers

  • I'm not sure why, but a few days later this problem just went away. I was expecting it to return eventually but it never has. I now wonder if there was something wrong on the Azure side because I never changed anything to fix it.

    Tim Archer

    • Marked as answer by Xethnic Saturday, December 5, 2015 4:01 PM
    Saturday, December 5, 2015 4:01 PM

All replies

  • Could the web page be timing out when loading the images? If you run Fiddler and capture the URL and show it in the browser by itself, does it display it or does it do the same thing?

    Robin

    Sunday, November 1, 2015 5:27 AM
  • I'm not sure why, but a few days later this problem just went away. I was expecting it to return eventually but it never has. I now wonder if there was something wrong on the Azure side because I never changed anything to fix it.

    Tim Archer

    • Marked as answer by Xethnic Saturday, December 5, 2015 4:01 PM
    Saturday, December 5, 2015 4:01 PM