The cloud is everywhere, which means your application can be everywhere too! However, in order to get the most out of globally scaled cloud infrastructure, you have to use the right cloud services.
For this project you will need:
- An Azure Account that isn’t on the free tier.
- Two web apps in separate regions in Azure
- Access to the Azure CLI either via install or Cloud Shell.
If you want some more context on creating web apps with Front Door, as well as globalizing databases with Cosmos DB, check out my more in-depth ACG project as well.
What is Azure Front Door?
One of the very real, and very cool, advantages of using a cloud computing platform like Microsoft Azure is the global footprint of the many regions, data centers, and edge nodes. In this project, we are going to take advantage of that with just a few simple steps using Azure Front Door and an App Service.
Front Door is a content delivery network (CDN) that takes your application and gives it a robust and high-performing global presence. Azure has thousands of edge nodes, which Front Door can place data on — meaning your application is much closer to the end user. For example, if you have an app service that is deployed to two regions on Azure, the Internet traffic to your app will have to go to either region.
If you use Front Door, the traffic will only need to reach an edge node. And if the request includes data that is either not on the edge node or outdated, only then will the App Service itself be queried.
Using Azure Front Door has several advantages, including:
- High performance: The time for your application to load and respond (latency) is much less, as traffic only needs to get to the edge node through Azure Front Door.
- High availability: Less data is transferred from your App Service Plans, helping to manage spikes and higher loads in traffic.
- SSL offloading: Traffic between the user and Front Door is automatically secured with SSL/TLS.
- Security: Protection against injection attacks, DDoS attacks, and bots.
Creating Azure Front Door
Now you know why you should use Front Door, so let’s look at how, using the Azure CLI.
az network front-door create --resource-group frontDoorRG --name codeproject-frontend --accepted-protocols http https --backend-address appservice-1.azurewebsites.net appservice-2.azurewebsites.net
In this case, the resource group is one you already have, and the two backend addresses are the URLs for your two app services. We are accepting both http and https into the front door instance. You can choose one of the two as well, depending on your requirements.
Even though creating and setting up an Azure Front Door is super easy, the story doesn’t stop here of course. I would recommend considering one or more of the following extra steps:
- Add a custom domain, such as llamadrama.com or partyhatsrus.com.au.
- Setting up a geo-filtering policy to block certain regions or countries.
- Configure a rules engine to control the traffic flow in more details.
- Use the rules engine to add security headers to prevent browser-based vulnerabilities.
Front Door is a simple and extremely effective service from Azure that will instantly let your web apps cater to a global audience and add a bunch of security features. You pay a monthly, relatively low price as a base , and then data transfers and numbers or rules come on top. Always check for yourself what you need and how it fits in with your budget.
For more information on creating web apps with Front Door, as well as globalizing databases with Cosmos DB, check out this ACG Project.