AzureRun Remix Run

Running Remix on the edge with Azure.

Intro

This post is about running Remix on Microsoft Azure. The focus of this article is on using Azure Frontdoor, Functions, DNS, Blob Storage and App Insights. CI/CD is done using GitHub actions.

Architecture Overview

An architecture overview showing how code is written with VSCode pushed to GitHub and deployed
via GitHub actions into an Azure environment. At the top of the image is a cloud show a request going into Azure, being processed by
Frontdoor to get content at the path /build/* from a CDN the other requests will be forwarded to an Azure Functions Apps running Remix.
The response gets security headers and cache headers appended by Frontdoor before returning it back to the cloud / client.

Remix - the new kid on the block

Remix is a full stack web framework that lets you focus on the user interface and work back through web fundamentals to deliver a fast, slick, and resilient user experience. People are gonna love using your stuff.

I come from building single page applications (SPA) with serverless backends. The developer experience (DX) is usually a bit tricky; you run a backend either locally or in the cloud and and a separate frontend. Another option is to use something like ASP.NET Core MVC, Ruby on Rails. Progressively enhancing these sites to build fancy user experiences can be tough, too.

Remix hits a sweet spot between the two. While delivering an excellent user experience (UX) you also get an excellent DX (developer experience).

Running at the edge

To avoid long waiting times for our customers we want to serve content from as close to the their location as possible. To route requests to the closest geolocation possible we setup Azure Frontdoor. Static content will be served from a content delivery network (CDN) and Azure Frontdoor will select the closest location of our Function App.

SSL

Frontdoor offers SSL certificate management. This takes away the work of getting and renewing certificates. Configuring your server for https is not a trivial task. To validate your configuration Qualys SSL Labs offers the SSL Test. The default setup for a custom domain gives excellent results.

A screenshot from a SSL Report by Qualys SSL Labs. The report is for the website www.devndive.com
showing in a table the four IP address the page is served from, two IPv4 and two IPv6. For all address a grade of A+ is given. The report
also includes the execution date and the time taken to generate it.

Content Delivery Network (CDN)

Frontdoor has a CDN build in. The CDN helps us to distribute content all over the world to be as close to users as possible.

We want content, we want it now!

Delivering content fast is very important to keep visitors happy. To measure performance of your site there are a few tools:

  • Lighthouse - Identify and fix common problems that affect your site's performance, accessibility, and user experience.
  • WebPageTest - Test. Optimize. Repeat. Get a good understanding what your site feels like for users from different countries.

Lighthouse

With lighthouse you can check your website for common issues. The default mode will test your application on a simulated mobile device. Mobile devices usually have a less power than high end notebooks. A lot of traffic now a days comes from mobile devices. Unless you have a different user base it is critical not forget about mobile users.

Next accessibility, best practices and SEO are tested. Do serve your images in modern formats? Did you add alt tags to your images? Did you ensure the contrast of font color to background color? Did you add metatags that show up on search result pages?

To make sure we can answer all questions with "Hell yes, I did!" you can use lighthouse during development and local testing. Ideally you integrate lighthouse or a similar tool into your CI/CD pipelines.

A report from lighthouse showing high scores in the categories performance, accessibility,
best practices and SEO

The users perspective

To get a better understanding what your page feels like for your users we need to check it from close to their geo location. Other circumstances to consider are internet speeds, what kind of hardware is accessible. A tool that can support us here is WebPageTest by Catchpoint.

You can run tests from a lot of different regions in the world. The resulting reports gives you very detailed information what the browser is doing. In the screenshot below you can see the so called filmstrip. You can scroll through the loading process of your page, see what the user is seeing and what the browser is doing at that point in time.

A screenshot showing a filmstrip report from WebPageTest.

WebPageTest offers an official GitHub action to integrate into your CI/CD workflow.

Continuous Integration / Continuous Deployment

To deploy the application when we push changes to our main branch we can use GitHub actions.

  • Deploying an Azure Functions App - https://github.com/Azure/functions-action
  • Deploying your static files - https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-static-site-github-actions