Hi @Laz6598
Thank you for reaching out to Microsoft Q&A.
You are experiencing intermittent 40–60 second delays in outbound connections from Azure Container Apps (ACA) to your database. This delay occurs before the request even reaches the database, which means the stall is happening inside the Azure Container Apps outbound networking layer. This issue is commonly seen when ACA uses shared SNAT ports, which can become exhausted under certain workloads. When SNAT ports are unavailable, outbound TCP connections can hang until they time out, typically causing the 40–60 second delay you are observing. Since the same container image works fine on AKS, the root cause is tied to ACA’s underlying infrastructure and not your application or the database. Other possible contributors include DNS latency inside ACA or cold starts if replicas scale from zero, but the symptoms strongly match SNAT exhaustion in ACA’s shared environment.
Refer below points to resolve this issue or use them as workarounds:
1. Deploy Azure Container Apps inside a VNET and use a NAT Gateway This gives your environment a dedicated outbound IP and a large pool of SNAT ports, eliminating the shared SNAT bottleneck. Steps:
- Create a VNET and subnet for ACA
- Create a NAT Gateway
- Attach the NAT Gateway to the subnet
- Deploy ACA Environment into this VNET
az network nat gateway create \ --name MyNatGateway \ --resource-group MyRG \ --public-ip-addresses MyPublicIP \ --idle-timeout 10 az network vnet subnet update \ --vnet-name MyVnet \ --name ACASubnet \ --resource-group MyRG \ --nat-gateway MyNatGateway
2. Enable and optimize database connection pooling If your app creates new outbound connections frequently, reduce connection churn by enabling pooling. This avoids repeated SNAT allocations and TCP handshakes.
- For .NET use default ADO.NET pooling
- For Node.js mssql enable pool settings
- For EF Core ensure
Max Pool Sizeis tuned
3. Use a private endpoint + private DNS zone (if applicable) If your database supports private endpoints, moving traffic to an internal VNET path will:
- Bypass public SNAT completely
- Avoid DNS fallback delays
- Improve reliability and latency