Lesson 2 of 3 Azure Firewall and Virtual WAN Security

Managing Azure Firewall Policies and Rules

This lesson explains how rule collections are structured, how rules are processed, and how policies are inherited.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the policy hierarchy.
  • Distinguish DNAT, network and application rules.
  • Explain the fixed processing order.
  • Explain parent and child policy precedence.

The firewall policy

A firewall policy is an Azure resource that holds rules and settings. It can be attached to one firewall or many, in several regions, and it replaces the older classic rules. A policy has a hierarchy: rule collection groups contain rule collections, which contain rules. Each group and each collection has a priority, from 100, which is highest, to 65,000, which is lowest. All rules in a collection share one action, allow or deny, and one rule type.

Azure Firewall Manager gives a central view for managing policies across firewalls.

Rule types

There are three rule types, each with a different purpose.

Rule typeFilters onExample
DNATInbound traffic to a firewall public address, which is translated to a private addressPublishing a service: 203.0.113.5:443 to 10.0.1.4:443
NetworkSource, destination, port and protocol, or FQDN in Standard and PremiumAllow UDP 123 to a time server
ApplicationFQDN, FQDN tags and web categories, over HTTP, HTTPS or MSSQLAllow outbound HTTPS to *.contoso.com
Sort into groups

DNAT, network or application rule?

Exam skills 2.3.8

Choose the rule type for each requirement.

Log in to try this activity Interactive activities are free with an account.

Processing order

Understanding the processing order is one of the most valuable things in this topic. Microsoft's documentation states that application rules are always processed after network rules, and network rules after DNAT rules, regardless of rule collection group priority, rule collection priority or inheritance.

  1. Threat intelligence

    Known malicious addresses and domains are handled first, if the mode is set to deny.

  2. DNAT rules

    Inbound traffic is translated.

  3. Network rules

    If a rule matches, processing ends, and application rules are not reached.

  4. Application rules

    These are evaluated if no network rule matched.

  5. Infrastructure rule collection

    A built-in collection allows Azure platform FQDNs.

  6. Deny

    Traffic that matches nothing is denied.

Within a type, rules are evaluated by rule collection group priority and then by rule collection priority, and the first match ends the process. Rules are terminating. Since network rules come first, a broad network rule that allows all TCP 443 traffic means that an application rule that denies a certain site never takes effect. This is a very common design error.

The following diagram shows the fixed order of rule types.

The order in which Azure Firewall processes rules. Threat intelligence handles known malicious addresses first when set to deny. DNAT rules translate inbound traffic. Network rules come next, and a match ends processing, so application rules are not reached. Application rules are evaluated only if no network rule matched, then the infrastructure rule collection, and anything left is denied. Priorities order rules within a type but never change this order.
Rules are terminating: the first match ends processing.

Priority does not change type order

An option that changes a priority number so that an application rule runs before a network rule is wrong. Priorities order rules within a type, and they never change the order between types.

Put in order

Rule type order

Exam skills 2.3.8

Put Azure Firewall's processing stages in order.

Log in to try this activity Interactive activities are free with an account.

Policy inheritance

A policy can be built on a parent policy, which suits a central team that sets organization-wide rules, while each application team has a child policy for its own firewall. Microsoft states that the parent policy always takes precedence over the child policy. The child inherits the parent's rules, and processes them first within each rule type, whatever the priorities in the child. The child can only add rules and cannot weaken the parent's.

DNAT and application rules

Inbound connections have a further point. Azure Firewall does not apply application rules to inbound connections. To let inbound HTTP traffic be inspected at layer 7, place an Application Gateway with a WAF in front. A DNAT rule translates the destination, and the translated traffic then needs an allowing route for its return traffic, or it will cause asymmetric routing: if a subnet's default route points to the firewall and the return path bypasses it, then the firewall drops the session as unknown.

IP groups hold reusable lists of addresses for rules. FQDN tags represent well-known Microsoft services, such as Windows Update, so that a person does not need to list them. Web categories allow or deny groups such as social networking, in Standard and Premium.

Troubleshooting scenario

Inbound and return traffic

Exam skills 2.3.8

Resolve problems with inbound traffic through Azure Firewall.

Log in to try this activity Interactive activities are free with an account.
Worked example

A rule that never fires

A policy has a network rule collection, at priority 300, that allows all outbound TCP 443 traffic. An application rule collection, at priority 100, denies *.badsite.example. Users can still reach that site. Why, and what should you change?

Network rules always run before application rules, whatever their priorities. The network rule matches outbound TCP 443 and ends processing, so the application rule never runs. The priority of 100 cannot change this, because it orders collections only within the same type.

Remove the broad network rule and allow HTTPS through application rules instead, with the deny collection at a higher priority than the allow collection. Alternatively, use a network rule with FQDN filtering for specific needs. Lowering the network rule's priority to 65,000 would not help.

Check yourself

Can a child policy override a deny in its parent?

Show answer

No. The parent policy always takes precedence over the child.

Exam Tips

Remember for the exam

  • DNAT runs first, then network, then application, whatever the priorities.
  • The first matching rule ends processing.
  • A parent policy always takes precedence over a child policy.
  • Application rules do not apply to inbound DNAT traffic.