Skip to content

Commit 7b85099

Browse files
committed
tweaks to scenario 10,11
1 parent d14a080 commit 7b85099

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed
45.4 KB
Loading
87.3 KB
Loading
109 KB
Loading

articles/frontdoor/rules-engine-scenarios.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -608,21 +608,40 @@ For more information, see [Preserve the original HTTP host name between a revers
608608

609609
### Scenario 10: If-elseif-else rules
610610

611-
The current rule engine in Azure Front Door does not natively support traditional conditional logic with "if-elseif-else" structures. Instead, all rules are independently evaluated as "if condition1 then action1," "if condition2 then action2," and so forth. This implies that if multiple conditions (e.g., condition1 and condition2) are simultaneously met, multiple corresponding actions (action1 and action2) will be executed.
612-
However, it is possible to emulate an "if-elseif-else" that resembles the following:
613-
- If condition1 is satisfied, execute action1.
614-
- Else if condition2 is satisfied (but condition1 is not), execute action2.
615-
- Else, execute a default action.
616-
If multiple conditions (condition1, condition2, ..., conditionN) are satisfied simultaneously, only the first matching action is executed, effectively simulating traditional conditional branching. If none of the conditions are met, the default action will execute.
617-
To configure this, create a new ruleset call it “IfElseifElseRuleset” and create rules as normal, the only change would be to check the Stop evaluating remaining rules box after each rule as shown below –
611+
The Azure Front Door rules engine doesn't natively support traditional conditional logic with "if-elseif-else" structures. By default, all rules are independently evaluated as "if condition1 then action1," "if condition2 then action2," and so forth. When multiple conditions are met simultaneously, multiple corresponding actions are executed.
618612

619-
Note: Due to limitations of current ruleset implementation, this if-elseif-else paradigm will only work if the ruleset is attached as the final ruleset for that route as shown below.
620-
Here is the Rule set configuration in Azure portal.
613+
However, you can emulate "if-elseif-else" logic by using the **Stop evaluating remaining rules** feature to create conditional branching that resembles:
614+
615+
- If condition1 is satisfied, execute action1 and stop
616+
- Else if condition2 is satisfied (but condition1 is not), execute action2 and stop
617+
- Else if condition3 is satisfied (but condition1 and condition2 are not), execute action3 and stop
618+
- Else, execute a default action
619+
620+
**How it works:** When multiple conditions would normally be satisfied simultaneously, only the first matching rule executes because rule evaluation stops after the first match. This effectively simulates traditional conditional branching.
621+
622+
**Configuration steps:**
623+
624+
1. Create a new ruleset (for example, "IfElseifElseRuleset")
625+
2. Create rules in priority order, with the most specific conditions first
626+
3. For each rule, check the **Stop evaluating remaining rules** option
627+
628+
:::image type="content" source="./media/rules-engine-scenarios/if-elseif-else-rules.png" alt-text="Screenshot that shows how to configure if-elseif-else rules." lightbox="./media/rules-engine-scenarios/if-elseif-else-rules.png":::
629+
630+
> [!IMPORTANT]
631+
> This if-elseif-else paradigm only works if the ruleset is attached as the **final** ruleset for that route.
632+
633+
:::image type="content" source="./media/rules-engine-scenarios/if-elseif-else-rules-final.png" alt-text="Screenshot that shows how to place if-elseif-else rules as the final ruleset for the route." lightbox="./media/rules-engine-scenarios/if-elseif-else-rules-final.png":::
621634

622635
### Scenario 11: Removing query strings from incoming URLs using URL redirects
623636

624-
To remove query strings from incoming URLs, implement a 3xx URL redirect to guide users back to the AFD endpoint with the query strings removed. Please note, users will notice the change of the request URL with this operation.
625-
Here is the configuration in rules engine in portal to strip the whole query string. If you need to strip part of it, you can adjust the offset/length as desired: Server variables - Azure Front Door | Microsoft Learn
637+
You can remove query strings from incoming URLs by implementing a 3xx URL redirect that guides users back to the Azure Front Door endpoint with the query strings removed.
638+
639+
[!NOTE]
640+
> Users will notice the change of the request URL with this operation.
641+
642+
The following example demonstrates how to remove the entire query string from incoming URLs. If you need to strip part of it, you can adjust the offset/length as desired. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
643+
644+
:::image type="content" source="./media/rules-engine-scenarios/remove-query-strings.png" alt-text="Screenshot that shows how to remove query strings from incoming URLs using URL 3xx redirects." lightbox="./media/rules-engine-scenarios/remove-query-strings.png":::
626645

627646
```json
628647
{

0 commit comments

Comments
 (0)