Azure CDN default document index.html
Asked Answered
B

4

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

Bacchius answered 22/12, 2015 at 10:12 Comment(0)
A
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/.

Aperture answered 22/12, 2015 at 10:34 Comment(0)
D
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

Dioptase answered 28/8, 2017 at 12:56 Comment(0)
R
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

Renzo answered 11/10, 2019 at 19:20 Comment(3)
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.Fletcherfletcherism
@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 SPARenzo
You can only have 1 static website per storage account correct?Absenteeism
A
0

As said by @KyleMit, it is possible uwith the Static website configuration on Azure Storage Account In the Static website configuration of the a Storage account, you have to set index.html to both the "index document name" and "the error Document Path"

Azure Storage Account - Static website configuration

Indeed, you must delegate to your SPA (angular/react...) all the routing mecanism, including the page not found error

Analysand answered 19/9, 2024 at 8:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.