Azure Front Door | Rules Engine

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.

References:
https://docs.microsoft.com/en-us/azure/frontdoor/front-door-rules-engine-match-conditions
https://docs.microsoft.com/en-us/azure/frontdoor/front-door-rules-engine-actions

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.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.