Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Azure Front Door to serve a SPA

I want to to be able to serve a SPA using just the Azure Front Door / and not Azure CDN. Looks like the Front Door provides the caching that the CDN would provide and I can add multiple regional storage accounts to it, making it global at scale.

The problem is, I can't match the path to index.html files. Found this feedback and it looks like this can be solved using the URL rewrite and redirect but couldn't figure out how.

I have /test/ and /test to match with the route below, so it should be matching /test and pointing the request to /test/index.html but this is not working. Can we not do file-based forwards?

enter image description here

like image 204
Mavi Domates Avatar asked Jun 29 '19 21:06

Mavi Domates


People also ask

What is azure front Door used for?

Azure Front Door is Microsoft's modern cloud Content Delivery Network (CDN) that provides fast, reliable, and secure access between your users and your applications' static and dynamic web content across the globe.

Should I use Azure front Door?

Azure Front Door Standard can be considered if we want to:Optimize content delivery. Provide for the acceleration of both static and dynamic content. Make use of basic security capabilities. Support global load balancing.

What is the difference between Azure front Door and CDN?

Azure CDN is best for delivering static content like Videos, Images and PDFs whereas Azure Front Door is for delivering sites, services and APIs. Azure CDN is cost-effective whereas Azure Front Door charges per ruleset. Azure CDN does all the functionality similar to Azure Front Door.

Which component of Azure front Door can be used to ensure that a specific user session remains on the same backend for the duration of the session?

Front Door and Application Gateway both support session affinity. While Front Door can direct subsequent traffic from a user session to the same cluster or backend in a given region, Application Gateway can direct affinitize the traffic to the same server within the cluster.


1 Answers

This took some time to figure out but here's the solution.

Create Blob Storage(s)

To host the SPA you'll need blob storage accounts in Azure and these storage accounts should be configured to receive static webpage traffic. Navigate to Settings and then Static website in the blob storage settings.

enter image description here

To add content here - navigate to your blob storage again and you should see a container named $web.

Now the $web container is the one that you should put all your static files in, just make sure it's publicly accessible (depending on how you created it, it might not be)

More documentation on how to make a static website using blob storage is here: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website

Get the static website endpoint

Once you enabled the static website and click on the static website blade, it should give you a different endpoint than the regular blob access endpoint - one that supports the static website. Something that looks like: https://somerandomstorageaccount.z8.web.core.windows.net/

Add the static website endpoint(s) to Azure Front Door as back-end

Navigate to your Front Door designer

enter image description here

Navigate to your Back-end pool and add a new entry if you don't have anything. You should now add this new website endpoint as a back-end to your Azure Front Door. Picture below is the update configuration, but adding it is equally simple, you just add it as a Custom Host back-end type and point it to your blob static website location.

enter image description here

To enable better performance, use multiple storage accounts (from different regions) and add all of those to back-end in your Front Door configuration and turn-on the caching in Front Door.

like image 124
Mavi Domates Avatar answered Oct 19 '22 01:10

Mavi Domates