9

I have now successfully setup my static website in a CDN, Is there a way to specify that index.html is the default document ? It is a 1 page site I just would like to browse to the root url without having to type /index.html ..

Thank you

fran6
  • 341
  • 1
  • 4
  • 14

3 Answers3

4

Based on your previous question, I am assuming that you have set CDN to map to blob storage. If this is correct, unfortunately it is not possible as of today because Azure Storage does not have a support for default document. This is one of the most requested feature on Azure Feedback - https://feedback.azure.com/forums/217298-storage/suggestions/1180039-support-a-default-blob-for-blob-storage-containers however it is still pending.

If you want, you can create a proper website (instead of having this index.html file in blob storage) and serve that website via CDN. You can find more details about it here: https://azure.microsoft.com/en-in/documentation/articles/cdn-websites-with-cdn/.

Community
  • 1
  • 1
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
4

Microsoft is working on this. At the moment you have only two possibilities to solve this:

  • Use CDN: With the premium version of Verizon you can create rules like Redirect Rules
  • Create an Web-App which act as a proxy and serves/redirects (to) blobs

Using Premium CDN If you purchased the premium version of Verizon CDN then you can create custom Rewrite rules. You'll find this in the "Advanced Features" section of your CDN endpoint. Once you click on "Manage" you will be redirected outside the portal where you can manage your cdn.

Rules Engine

Hier you must create a redirect rule like this:

enter image description here Note that each change in a rule takes about 5 hours to be activated.

To check if your redirect rule works you can install IIS and activate the URL Rewrite Module. In the Rewrite Module you can test your rules.

  1. Open IIS
  2. Open Url Rewrite Module
  3. Add Rule
  4. Add blank rule
  5. Test Pattern

Please note that if you test your pattern, it must begin with the CDN source path which is a number and your endpointname like /829292/movies.

enter image description here

Sometimes redirect rules causes problems with CDN Purging. You can solve this isssue by adding an if clause in your rule which says that redirect should only be active if it is not the purge agent.

enter image description here

Baris Bikmaz
  • 401
  • 3
  • 11
3

This is now possible with Static websites on Azure Storage

Creating a Static Website

  1. Navigate to your storage account
  2. Select Static Website from the blade and toggle to "enabled"

    Add Static Website

  3. Once you save, this will create a URL endpoint and also a bucket named $web to host your files

    Static Endpoint

  4. Go to your $web storage container and upload any files you want

Add CDN / Custom Domain

  1. Navigate to your CDN Profile and either Create / Edit your Endpoint
  2. Select 'Custom Origin' and use the 'Origin Hostname' that was created for your static site

    Custom Origin CDN

  3. Give Azure up to 30 minutes to propagate all the settings

Further Reading

KyleMit
  • 30,350
  • 66
  • 462
  • 664
  • 1
    I don't believe this addresses the problem of making it serve up the `index.html` for all URL Paths. You can put the `index.html` in the "Error Document Path" setting of the Static website which sort of works except the response is 404:NotFound. – oatsoda Jun 16 '20 at 07:31
  • 1
    @oatsoda, yeah, i believe you are correct - this won't route all traffic to `/index.html` if you needed deep links to all get served from a SPA built from a single index page, but this should at least allow for cleaner URLs if using folder based routing or hash routing with a SPA – KyleMit Jun 16 '20 at 14:19
  • You can only have 1 static website per storage account correct? – Enrico Sep 08 '20 at 10:40