1

We have a static website (angular) hosted in a Azure Blob Storage with a web$ folder and all options set.

See picture below:

enter image description here enter image description here

When we put the website in the root folder web$ of the blob storage, everything works fine. And when we reload the page, all pages/routes are redirected to the index.html of our SPA.

But we need to host several static sites on the same web$ folder. So we created folders and set the option "Origin Path" to the target folder for each endpoint created.

We have now: /folder1/index.html for the first endpoint in the CDN /folder2/index.html for the second endpoint in the CDN

Everything works fine but not the reload. As soon as we refresh the page, the endpoint of the CDN doesn't retrieve the target folder.

We have another project where the same configuration is working fine but we found that it is the serviceworker of our PWA which is caching the index.html (not the CDN) But we need a solution without serviceworker.

Maybe with a redirect rule?

[Edit] 02-march-2019

Here is the printscreen of the error when I try to reload

enter image description here

And here is the configuration for One of the multiple endpoints we have:

enter image description here

And the content of our Web$ folder in our container:

enter image description here

hugo
  • 1,829
  • 1
  • 18
  • 47

2 Answers2

0

If you want to use the CDN for every "subfolder" path on your origin path, try to enter /folder1 or /folder2 in the Origin path field.

For Azure CDN endpoints return a 404 status code, there are several possible causes, including:

  • The file's origin isn't visible to the CDN.
  • The endpoint is misconfigured, causing the CDN to look in the wrong place.
  • The host is rejecting the host header from the CDN.
  • The endpoint hasn't had time to propagate throughout the CDN

You could try the troubleshooting steps.

Nancy
  • 26,865
  • 3
  • 18
  • 34
  • That's what we did. It works when you load the page, not when you reload the page (F5 with your browser) – hugo Feb 29 '20 at 19:40
  • do you have all website files in the same "subfolder"? Could you show the page when you F5? – Nancy Mar 02 '20 at 01:44
  • I edited my question with all printscreens and information. All our websites are located in different folders (1 subfolder for 1 website) – hugo Mar 02 '20 at 10:17
  • No idea, you may consider using the original blob URL like https://storageaccount.blob.core.windows.net/$web/subfolder/index.html. then change the `origin type` to a storage account and `public access level` to container level and origin path. What's the result? If no luck, you can put 1 container (not inside the $web) for 1 website. – Nancy Mar 12 '20 at 09:36
  • That's what we did. 1 container for 1 website. – hugo Mar 12 '20 at 21:53
0

You actually don't need the Azure Storage static website feature anymore. You can just create a custom container (like your folder1, not as subfolder but as container) and use as Origin Path "/folder1/index.html". You probably need to set up some rules in the rules engine to make it work properly after reload, depending on your needs.

azure cdn index rewrite rule

You might also want to have some redirect rules for SPAs like I explained here Hosting SPA with Static Website option on Azure Blob Storage (clean URLs and Deep links) Andreas

Dharman
  • 30,962
  • 25
  • 85
  • 135
Andreas Wendl
  • 594
  • 5
  • 7