4

I tried uploading an HTML file to my azure blob storage, and retrieved the link.
Unfortunately, when entering the URL into a web browser, it does not load the page, it tries to download it.

How can I make HTML files on Azure CDN load as web pages, not downloads?

  • Thanks
  • I tried to find this in other questions and on google, but had no luck. I found numerous references on using Azure CDN for hosting html files, but nothing showing how to get around this forced download issue I'm running into. –  Sep 17 '15 at 20:34
  • This is the link I'm downloading: https://codavore.blob.core.windows.net/general/Unity3D/LyndaRtsPass2/index.html –  Sep 17 '15 at 20:35
  • The CDN path is this: http://az806498.vo.msecnd.net/general/Unity3D/LyndaRtsPass2/index.html I can't get this to work from either. –  Sep 17 '15 at 20:45

2 Answers2

3

FIXED! Turns out in Azure, I need to edit the properties of the html file, and set the content type to text/html. :)

1

We need to set it's property Content type through Blob Options class.

PHP :

    namespace - use MicrosoftAzure\Storage\Blob\Models\CreateBlobOptions;
    //use code where you are creating blob
    $opts = new CreateBlobOptions();
    //$opts->setCacheControl('test');
    $opts->setContentEncoding('UTF-8');
    $opts->setContentLanguage('en-us');
    //$opts->setContentLength(512);
    $opts->setContentMD5(null);
    $opts->setContentType($mimeType);
    $blobRestProxy->createBlockBlob($containerName, $indexFile, $content,$opts);

It will work in git package : "microsoft/windowsazure": "^0.5"

In C#

entryData.DestinationBlob.Properties.ContentType = "image/jpeg";
entryData.DestinationBlob.SetProperties();
Shubham
  • 37
  • 4