Azure Front Door | Rules Engine
Azure Front Door Rules Engine is a new feature that gives you more control in how you define and enforce what content gets served from where. Rules Engine allows you to specify how HTTP requests are handled from the AFD. Different combinations of match conditions and actions give you fine-grained control over which users get which content and make the possible scenarios that you can accomplish with Rules Engine endless.
For example, you can use a match condition to:
- Filter requests based on a specific IP address, country, or region.
- Filter requests by header information.
- Filter requests from mobile devices or desktop devices.
The following match conditions are available to use in Front Door Rules engine:
- Device type
- Post argument
- Query string
- Remote address
- Request body
- Request header
- Request method
- Request protocol
- Request URL
- Request file extension
- Request file name
- Request path
- Standard operator list
How Rules Engine Works
The Rules Engine applies the routing roules at the Edge. Once the request is received from the AFD edge location, the Rules Engine routes it first through the WAF rules and right after it applies the route configuration. In the next picture, the Rules Engine desides if the request will redirected to the mobile site or it will be forwarded to the desktop site.
How to create a rules engine and add a rule
We will create a rule to redirect the requests to the Desktop or to the Mobile site, based on the clients device type.
Go to the Front Door, and select the “Rules engine configuration” at the Settings section. Press “+ Add” to create a rules engine.
Type a name for the Rules engine, and a name for the first rule. Once you press the “+Add a condition” a drop down menu will open with all the available condition types.
For our example I selected the “Device type” condition and I selected that the request is Equal to Mobile.
Then press the “+ Add an action” to view the available actions.
for our example I selected to forward the request to the /mobile.html, where is the mobile site.
Finally, you need to Associate the routing rule, by selecting the three dots at the right of the rule.
and select the front door that you want this rule to be applied.
You can find more AFD posts at my blog, like create an Azure Front Door to scale and secure our web apps, Azure Front Door add custom domain & certificate and we use Web Application Firewall (WAF) rules to protect our web apps.
Pantelis Apostolidis is a Cloud Solutions Architect at Microsoft and an ex Microsoft Azure MVP. For the last 15 years, Pantelis has been involved to major cloud projects in Greece and abroad, helping companies to adopt and deploy cloud technologies, driving business value. He is entitled to a lot of Microsoft Expert Certifications, demonstrating his proven experience in delivering high quality solutions. He is an author, blogger and he is acting as a spokesperson for conferences, workshops and webinars. He is also an active member of several communities as a moderator in azureheads.gr and autoexec.gr. Follow him on Twitter @papostolidis.