Homeβ€Ί Blogβ€Ί Azure Architecture Series #96 β€” Load Balancer Outbound Rules…
Azure Architecture Azure Architecture Series

Azure Architecture Series #96 β€” Load Balancer Outbound Rules

Verified against current vendor documentation on 17 November 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.

Business Challenge

#95 covered the inbound half of this service: a rule, a hash, a probe. Outbound is a different mechanism entirely, and it is the one that fails under load.

The reason is arithmetic. Outbound connections from a private address need source NAT, SNAT consumes a port per flow, and ports are finite per public IP:

64,000 is the whole budget

“By definition, every IP address has 65,535 ports… When you add a public IP address as a frontend IP to a load balancer, 64,000 ports are eligible for SNAT.”

That budget is then divided among every instance in the backend pool, and the default division is deliberately stingy. Microsoft says so in its own voice:

The default is documented as unsuitable for production

“Don't use default port allocation for production workloads, as it allocates a minimal number of ports to each backend instance and increases the risk of SNAT port exhaustion.”

So the feature in this post's title exists to fix a default that ships broken for anything serious — and even then, the same documentation ranks the fixed version third.

Architecture

Diagram: Load Balancer outbound rules across four bands. The first band is the port budget. A public IP carries 65,535 ports in total, of which 64,000 are eligible for SNAT once that address becomes a load balancer frontend. Every load-balancing rule and inbound NAT rule consumes a block of eight ports from that same budget when the frontend is shared between inbound and outbound, and ports are only ever handed out in multiples of eight. The second band is the default allocation table, which divides the budget by backend pool size: a pool of one to fifty instances receives one thousand and twenty-four ports each, fifty-one to one hundred receives five hundred and twelve, one hundred and one to two hundred receives two hundred and fifty-six, two hundred and one to four hundred receives one hundred and twenty-eight, four hundred and one to eight hundred receives sixty-four, and eight hundred and one to one thousand receives thirty-two. The allocation is per frontend IP but capped: the formula is the minimum of the per-pool figure multiplied by the number of frontend IPs, and one thousand and twenty-four. So at one hundred instances a second frontend IP doubles five hundred and twelve to the cap, and a third frontend adds nothing at all. The third band is what an outbound rule changes. It lets you set which backends translate to which public addresses, how many ports each instance gets, which protocols are translated, an idle timeout between four and one hundred and twenty minutes, and whether a TCP reset is sent when that timeout fires. Manual allocation is calculated as the number of frontend IPs multiplied by sixty-four thousand divided by the number of backend instances, and the platform rejects any allocation that would oversubscribe the budget, such as seven instances asking for ten thousand ports each against a single public IP. Taking control of an address already used for inbound requires setting disableOutboundSnat to true first, and doing that without then defining an outbound rule leaves the machines with no outbound connectivity at all. The fourth band is the ranking the documentation itself publishes. NAT Gateway on the subnet is rated best, with dynamic explicit port allocation. An instance-level public IP is rated OK. Load balancer outbound rules are rated OK, production-grade yes but not at scale. A load balancer frontend used for outbound without rules, and default outbound access, are both rated worst. NAT Gateway additionally takes precedence over all of them for new connections.
A fixed budget, a default that divides it badly, and a feature rated third by the people who built it.

Where the ports go by default

Pool size (VM instances)Default SNAT ports, per frontend IP
1–501,024
51–100512
101–200256
201–400128
401–80064
801–1,00032

From top to bottom the per-instance allocation falls by a factor of 32. An instance in a thousand-strong pool gets 32 ports — which is to say, 32 simultaneous connections to any single destination IP and port, before new ones start failing.

The part that catches people is the ceiling on top of the table:

Adding public IPs stops helping at 1,024

“with 100 VMs in a backend pool and only one frontend IP, each VM receives 512 ports. If you add a second frontend IP, each VM receives an extra 512 ports… a total of 1,024 ports. As a result, adding a third frontend IP doesn't increase the number of allocated SNAT ports beyond 1,024.”

The formula is MIN(ports-for-pool-size × frontend IPs, 1024). So the obvious remedy for exhaustion — throw another public IP at it — works exactly once at a hundred instances, and not at all for a pool already receiving 1,024. Under default allocation the only lever left is shrinking the pool.

What an outbound rule actually buys

The rule replaces that table with numbers you choose. It controls “which virtual machines are translated to which public IP addresses… how outbound SNAT ports are allocated… which protocols to provide outbound translation for… what duration to use for outbound connection idle timeout (4-120 minutes)… whether to send a TCP Reset on idle timeout”.

The allocation maths is published: “Number of frontend IPs * 64K / Number of backend instances”. And the platform checks it — “if you give 10,000 ports per VM and seven VMs in a backend pool share a single public IP, the configuration is rejected”, because 70,000 exceeds 64,000. Oversubscription is refused at configuration time rather than discovered at runtime, which is the single most useful property of the feature.

Two mechanical details to know before writing one:

  • Ports come in multiples of eight. “If you provide a value not divisible by 8, the configuration operation is rejected.”
  • Inbound rules eat the same budget. “Each port used in a load balancing or inbound NAT rule consumes a range of eight ports from the 64,000 available SNAT ports” when the frontend is shared. Rules landing in the same block of eight cost nothing extra.

Why This Architecture Holds Up

Because exhaustion is per-instance, and the load balancer looks fine

A healthy load balancer with a dead backend

“SNAT exhaustion occurs when a backend instance runs out of given SNAT ports. A load balancer can still have unused SNAT ports. If a backend instance's used SNAT ports exceed its given SNAT ports, it can't establish new outbound connections.”

So the metric that would tell you — ports used across the load balancer — can read comfortable while one instance is completely unable to make outbound calls. The allocation is static and per-instance; the traffic is not. One noisy backend exhausts its own share and nothing rebalances.

The symptom is also unhelpfully specific: “New outbound connections to a destination IP fail when port exhaustion occurs. Connections succeed when a port becomes available.” Intermittent connection failures to one destination, under load, that clear by themselves — which reads like the destination's problem.

Because TCP and UDP consume the budget differently

ProtocolPort consumption
TCPA port “can be reused for a connection to a different destination IP address or a different destination port” — so one port serves many flows, as long as the destination differs.
UDP“a port-restricted cone NAT algorithm, which consumes one SNAT port per destination IP, regardless of the destination port.”

That asymmetry is large and rarely modelled. A workload talking TCP to a thousand ports on one host consumes a handful of SNAT ports; the same pattern over UDP consumes one port per destination host and no more, but gains nothing from port variety. Any capacity estimate built on connection counts alone will be wrong for one of the two.

Ports also do not come back immediately: “When a connection is idle with no new packets being sent, the ports are released after 4 to 120 minutes” — the idle timeout you set on the outbound rule is simultaneously how long a dead flow holds a port hostage. Raising it to protect long-lived connections directly reduces effective port capacity.

Because taking control has a step where everything stops

An address used for inbound cannot simply be re-tuned. “To change the SNAT port allocation of an address also used for inbound, the disableOutboundSnat parameter must be set to true”, and the operation “fails if you attempt to redefine an IP address that is used for inbound” without doing so.

The intermediate state has no outbound connectivity at all

“Your virtual machine won't have outbound connectivity if you set this parameter to true and don't have an outbound rule to define outbound connectivity. Some operations of your VM or your application can depend on having outbound connectivity available.”

Two changes that must be adjacent, where the gap between them is a total egress outage for the pool — including whatever the operating system quietly needs, which #68's private-subnet material flags as covering Windows Activation and Windows Update.

Because scale sets want a different allocation model

Ports per instance is the recommended model for virtual machines. For scale sets it is the wrong one:

“If you have Virtual Machine Scale Sets in the backend, it's recommended to allocate ports by maximum number of backend instances. If more VMs are added to the backend than remaining SNAT ports allowed, scale out of Virtual Machine Scale Sets could be blocked, or the new VMs won't receive sufficient SNAT ports.”

A port allocation sized for today's instance count becomes a scaling ceiling tomorrow, and it fails in the worst way available: the autoscale event that was supposed to absorb a traffic spike is blocked by the port maths, during the spike.

The related trap is membership. “All virtual machines within a virtual machine scale set must be added to the backend pool for outbound connectivity”, and the same for availability sets — partial membership means partial egress.

Because the documentation ranks this feature third, in public

#MethodPort allocationProduction-grade?Rating
1NAT Gateway on the subnetDynamic, explicitYesBest
2Public IP on the virtual machineStatic, explicitYesOK
3Load balancer frontends via outbound rulesStatic, explicitYes, but not at scaleOK
4Load balancer frontends without outbound rulesStatic, implicitNoWorst
5Default outbound accessImplicitNoWorst

It is unusual for a product team to publish a table placing its own feature third and qualifying it with “not at scale”. Taken at face value it is a strong recommendation: the word static in row three is the whole problem, and row one's dynamic is the whole fix.

NAT Gateway “dynamically allocates source NAT (SNAT) ports” and “doesn't have the same limitations of SNAT port exhaustion as default outbound access and outbound rules of a load balancer”. It also wins by default: it “takes precedence over other outbound connectivity methods, including a load balancer, instance-level public IP addresses, and Azure Firewall”.

That precedence deserves attention in its own right, because it means adding a NAT Gateway silently retires your outbound rule's role for new connections. The published order, from winning to losing, is: a UDR to an appliance or gateway, then NAT Gateway, then an instance-level public IP, then load balancer outbound rules, then the default system route. An outbound rule is fourth of five in that chain, and three things above it can be introduced by someone else.

One genuine incompatibility to carry: “IPv6 outbound traffic that uses load balancer outbound rules is disrupted when you associate a StandardV2 NAT gateway with a subnet.” A dual-stack estate cannot simply layer the two.

Because the ground shifted underneath this in March

#68 covered the retirement of implicit egress when it was still ahead. It has landed: “For the API version released after March 31, 2026, subnets in new virtual networks have defaultOutboundAccess set to false by default.”

The scope is narrower than “retirement” suggests, and the distinction matters for planning: “Existing virtual networks aren't changed”, and virtual machines in them keep receiving default outbound IPs unless a subnet is made private deliberately. So the estate splits into networks built before and after a date, with different egress behaviour and no visible difference in the resource.

Two details that bite during the transition:

  • “Existing virtual machines must be stopped and deallocated” for a subnet's privacy change to take effect on their NICs. Not restarted — deallocated.
  • In a private subnet, “any configured routes with next hop type Internet break”. That is precisely the pattern of sending 0.0.0.0/0 to an appliance while exempting specific service tags straight to the internet — a design #79 and #78 both describe as standard practice.

And one known defect worth knowing before choosing a backend pool type: “When a load balancer backend pool is configured by IP address, it uses default outbound access due to an ongoing known issue”, which the outbound rules page restates as the pool behaving “as a Basic Load Balancer with default outbound enabled”. #95 presented IP-based pools as the more flexible option; for outbound security they are the weaker one.

Because the cheapest fix is not to need SNAT

Buried in the SNAT documentation is the advice that removes the problem rather than sizing it:

Private Link spends no ports

“If you need to connect to any supported Azure PaaS services like Azure Storage, Azure SQL, or Azure Cosmos DB, use Azure Private Link to avoid SNAT entirely. Azure Private Link sends traffic from your virtual network to Azure services over the Azure backbone network instead of over the internet.”

For a workload whose outbound traffic is mostly to Azure PaaS — which is most of them — that converts a port-budget problem into a #94 DNS problem. Which is a real trade and not a free one, but the ports stop being the constraint.

The other application-side lever is stated just as plainly: “Use connection reuse functionality within your application. Without connection reuse, the risk of SNAT port exhaustion is increased.” A connection pool is a port multiplier, and it is usually a one-line configuration change in the client library.

Key Architecture Decisions

DecisionChoiceWhy
Default outbound method for new workloads NAT Gateway on the subnet Microsoft's own ranking puts it first with dynamic allocation; outbound rules are third and qualified as “not at scale”.
Relying on default SNAT port allocation Never in production Documented as allocating a minimal number of ports and increasing exhaustion risk. A 1,000-instance pool gets 32 ports each.
Fixing exhaustion by adding public IPs Only works with an explicit outbound rule Under default allocation the total is capped at 1,024 ports per instance, so a third frontend IP adds nothing.
Allocation model for scale sets Maximum number of backend instances, not ports per instance Sizing to today's count can block a future scale-out or leave new instances with too few ports — during the event that triggered the scaling.
Idle timeout on the outbound rule Treat it as a capacity setting, not a reliability one Ports are held for 4 to 120 minutes after a flow goes idle, so raising the timeout directly reduces effective port capacity.
Taking over an inbound address for outbound tuning Set disableOutboundSnat and create the outbound rule as one change The intermediate state has no outbound connectivity at all, which breaks OS-level dependencies as well as the application.
Backend pool type when outbound matters NIC-based An IP-based pool is documented as using default outbound access due to a known issue, behaving like a Basic load balancer with default outbound enabled.
Capacity modelling for UDP workloads Model per destination IP, not per connection UDP uses port-restricted cone NAT: one SNAT port per destination IP regardless of port, where TCP reuses a port across differing destinations.
Monitoring for exhaustion Per-instance, never load balancer aggregate A backend can be fully exhausted while the load balancer still reports unused SNAT ports.
Outbound to Azure PaaS Private Link, and spend no ports at all Documented as the way to avoid SNAT entirely; it moves the problem to DNS, which is a known and solvable one.
Introducing a NAT Gateway alongside existing outbound rules Treat it as replacing them NAT Gateway takes precedence for all new connections, and with StandardV2 it actively disrupts IPv6 traffic using outbound rules.
New virtual networks after 31 March 2026 Plan explicit egress before the first workload Subnets default to defaultOutboundAccess = false, and routes with next hop type Internet break in a private subnet.

Closing Thought

Every other networking feature in this series fails because of a rule somebody wrote, a name somebody mistyped, or a default somebody did not read. Outbound SNAT fails because of division. A fixed number of ports is split statically among instances before anyone knows how the traffic will actually distribute, and the split cannot adapt afterwards.

That is why the remedies divide so cleanly into two kinds. One kind makes the number bigger — more public IPs, a manual allocation, a bigger prefix — and all of them eventually meet the same ceiling, because the budget per address does not move. The other kind removes flows from the calculation entirely: connection reuse, so a thousand requests share one port; Private Link, so Azure PaaS traffic never leaves the backbone and never needs a port at all; and NAT Gateway, which stops pre-dividing the budget and hands ports out on demand.

And the one that explains the ranking

The difference between “OK” and “Best” in Microsoft's own table is a single word in the port-allocation column: static versus dynamic. Everything else about outbound rules — the declarative control, the explicit addresses, the rejection of oversubscribed configurations — is genuinely good engineering built on top of a division that happens too early.

Which makes the honest summary of this feature something like: use it when you need traffic to leave from specific, known addresses and the scale is modest, and reach for NAT Gateway the moment either of those stops being true.

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent