Using a URL Rewrite in the Rule sets in the preview version of Frontdoor show unexpected behaviour with regards to source path selector and leading slash

Peter Moolenaar 96 Reputation points
2021-08-16T12:41:16.297+00:00

When trying to configure an Azure Front Door Standard (preview) with an API Origin and a static content origin the Rule engine I came across an issue not allowing me full freedom in rewriting paths.
Using two origins and two routes with path selectors whereas one has a 'fall-thru' /* and the other has /api and /api/* defined the requests from the front-end route to the correct origin.
However, there is a need to do some rewriting of the paths for those requests that match /api/* so a rule set is created attached to that route. However even the most basic rewrite fails. Doing some digging it appears that the URL Path on which the rewrite logic is likely to be performed is missing its leading slash, and setting a Source pattern without leading slash is not allowed.
To ensure there are configurations wherein it is working as expected I also created another configuration which is indeed working as expected (albeit non useful in my situation).

Attached some screenshots of both the working (but useless) and non-working configurations and some evidence (App Insights at the Origin) thereof.

Am I alone in this behavior, is there something I overlooked or is this a bug in the service itself?

Working config
123625-working-rule.png

Working 'evidence'
123605-working-appinsights-metric.png

Non-working config and evidence
123586-non-working-rule.png
123577-non-working-appinsights-metric.png

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
677 questions
Azure Content Delivery Network
0 comments No comments
{count} votes

Accepted answer
  1. Peter Moolenaar 96 Reputation points
    2021-11-18T08:54:09.913+00:00

    The mentioned 'resolution' below was indeed something that came available after some time. The mentioned documentation was updated just days before the resolution was presented to me. :D
    On top of that, I noticed the actual validation logic on some of the input fields was changed to allow this procedure.

    <<<<<UPDATE>>>>>

    Hello @Peter Moolenaar ,

    Below is the summary from the support engineer which resolved the issue:

    On checking the configuration, we could see that the origin path is empty in your associated route.

    Please find the below document for reference which was updated with some new information recently:
    URL redirect and URL rewrite with Azure Front Door Standard/Premium (Preview) | Microsoft Learn

    Currently, source pattern uses a prefix-based match.

    For URL rewrite source pattern, only the path after the route configuration “patterns to match” is considered.

    For example, you have the following incoming URL format <Frontend-domain>/<route-patterns-to-match-path>/<Rule-URL-Rewrite-Source-pattern>, only /<Rule-URL-Rewrite-Source-pattern> will be considered by the rule engine as the source pattern to be rewritten. Therefore, when we have a URL rewrite rule using source pattern match, the format for the outgoing URL will be <Frontend-domain>/<route-patterns-to-match-path>/<Rule-URL-Rewrite-destination>.

    For scenarios, where /<route-patterns-to-match-path> segment of the URL path must be removed, it is required to set the Origin path of the Origin group in route configuration to /.

    Hence, request you to kindly navigate to the Endpoint manager in your Azure Front door standard and click on “Edit Endpoint”. In the respective route, kindly enter the origin path as "/".

    Also you can dissociate the ruleset which was attached earlier to this route.
    Then click on “Update” to save this configuration.

    Post that kindly click on Purge cache in the overview section of Front door standard.

    And after 5-10mins, kindly browse the URL and check if the re-write URL is working as expected. If not kindly purge cache again and after 5-10mins browse the URL.
    If this doesn’t work, associate the ruleset configured earlier to this route, purge cache and check the same (kindly keep the origin path set to "/" and do not remove it).

    You followed the above and this resolved your issue.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. GitaraniSharma-MSFT 49,591 Reputation points Microsoft Employee
    2021-08-25T12:55:02.07+00:00

    Hello @Peter Moolenaar ,

    Apologies for the delay in response.

    I checked internally but couldn't find any existing bug relating to your issue. This issue would require a deeper investigation, so if you have a support plan, I request you file a support ticket, else please do let us know, we will try and help you get a one-time free technical support.

    Thanks,
    Gita

    0 comments No comments

  2. GitaraniSharma-MSFT 49,591 Reputation points Microsoft Employee
    2021-11-18T07:03:33.077+00:00

    <<<<<UPDATE>>>>>

    Hello @Peter Moolenaar ,

    Below is the summary from the support engineer which resolved the issue:

    On checking the configuration, we could see that the origin path is empty in your associated route.

    Please find the below document for reference which was updated with some new information recently:
    URL redirect and URL rewrite with Azure Front Door Standard/Premium (Preview) | Microsoft Learn

    Currently, source pattern uses a prefix-based match.

    For URL rewrite source pattern, only the path after the route configuration “patterns to match” is considered.

    For example, you have the following incoming URL format <Frontend-domain>/<route-patterns-to-match-path>/<Rule-URL-Rewrite-Source-pattern>, only /<Rule-URL-Rewrite-Source-pattern> will be considered by the rule engine as the source pattern to be rewritten. Therefore, when we have a URL rewrite rule using source pattern match, the format for the outgoing URL will be <Frontend-domain>/<route-patterns-to-match-path>/<Rule-URL-Rewrite-destination>.

    For scenarios, where /<route-patterns-to-match-path> segment of the URL path must be removed, it is required to set the Origin path of the Origin group in route configuration to /.

    Hence, request you to kindly navigate to the Endpoint manager in your Azure Front door standard and click on “Edit Endpoint”. In the respective route, kindly enter the origin path as "/".

    Also you can dissociate the ruleset which was attached earlier to this route.
    Then click on “Update” to save this configuration.

    Post that kindly click on Purge cache in the overview section of Front door standard.

    And after 5-10mins, kindly browse the URL and check if the re-write URL is working as expected. If not kindly purge cache again and after 5-10mins browse the URL.
    If this doesn’t work, associate the ruleset configured earlier to this route, purge cache and check the same (kindly keep the origin path set to "/" and do not remove it).

    You followed the above and this resolved your issue.

    ----------------------------------------------------------------------------------------------------------------

    Please "Accept the answer" to help us and others in the community as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.