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:
“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:
“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
Where the ports go by default
| Pool size (VM instances) | Default SNAT ports, per frontend IP |
|---|---|
| 1–50 | 1,024 |
| 51–100 | 512 |
| 101–200 | 256 |
| 201–400 | 128 |
| 401–800 | 64 |
| 801–1,000 | 32 |
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:
“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
“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
| Protocol | Port consumption |
|---|---|
| TCP | A 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.
“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
| # | Method | Port allocation | Production-grade? | Rating |
|---|---|---|---|---|
| 1 | NAT Gateway on the subnet | Dynamic, explicit | Yes | Best |
| 2 | Public IP on the virtual machine | Static, explicit | Yes | OK |
| 3 | Load balancer frontends via outbound rules | Static, explicit | Yes, but not at scale | OK |
| 4 | Load balancer frontends without outbound rules | Static, implicit | No | Worst |
| 5 | Default outbound access | Implicit | No | Worst |
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
Internetbreak”. That is precisely the pattern of sending0.0.0.0/0to 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:
“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
| Decision | Choice | Why |
|---|---|---|
| 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.
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.
Official Azure Reference
- Outbound rules for Azure Load Balancer — what an outbound rule controls, scaling with extra IPs and prefixes, the multiples-of-eight rule, the rejected over-allocation example,
disableOutboundSnatand its outage, the IP-based backend pool warning, and the limitations - SNAT for outbound connections — the five-method precedence table and its ratings, the 64,000 port budget, the default allocation table and its 1,024 cap, port exhaustion and its per-instance nature, TCP versus UDP port reuse, the release timers, and the Private Link recommendation
- What is Azure NAT Gateway? — dynamic SNAT allocation, precedence over other outbound methods, the Standard and StandardV2 SKUs with their throughput and IP limits, the idle and port-reuse timers, and the StandardV2 IPv6 known issue
- Default outbound access in Azure — the 31 March 2026 API change, what is and is not affected, the stop-and-deallocate requirement, the next-hop-Internet limitation in private subnets, and the IP-based backend pool known issue
- Configure TCP idle timeout — the timeout mechanics referenced above, for further reading (no claims drawn from it)
- Migrate outbound access to Azure NAT Gateway — the documented migration path from outbound rules, for further reading (no claims drawn from it)
Comments