Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure: WebContentNotFound on refreshing page of SPA deployed as Azure Blob Static Website with CDN

I have a SPA (built with angular) and deployed to Azure Blob Storage. Everything works fine and well as you go from the default domain but the moment I refresh any of the pages/routes, index.html no longer gets loaded and instead getting the error "the requested content does not exist"

Googling that term results in 3 results total so I'm at a loss trying to diagnose & fix this.

like image 656
SebastianG Avatar asked Apr 02 '19 15:04

SebastianG


People also ask

How do I deploy a static website on Azure?

Configure static website hostingOpen the Azure portal in your web browser. Locate your storage account and display the account overview. Select Static website to display the configuration page for static websites. Select Enabled to enable static website hosting for the storage account.

Does CDN work with Azure storage?

In this quickstart, you enable Azure Content Delivery Network (CDN) to cache content from Azure Storage. Azure CDN offers developers a global solution for delivering high-bandwidth content.

What is Blob URI in Azure?

Definition. The BlobUriBuilder class provides a convenient way to modify the contents of a Uri instance to point to different Azure Storage resources like an account, container, or blob. For more information, see Naming and Referencing Containers, Blobs, and Metadata.


2 Answers

You can simply configure the error page to index.html in your static website:

enter image description here

like image 111
Ahmed Shendy Avatar answered Oct 14 '22 07:10

Ahmed Shendy


Actually the issue was I didn't have 404.html defined -- the blob storage for SPA doesn't understand what file to serve for any other routes than the root one. So every other route will go to the 404 file. But in a SPA even the 404 goes through the index file. So all I did is mention index.html as my 404 file and all is well.

like image 40
SebastianG Avatar answered Oct 14 '22 07:10

SebastianG