Best API Gateway for .NET Core Microservices, Picked
If you're running a .NET Core microservices architecture and searching for "best api gateway for microservices net core," you're likely at one of two points: you're outgrowing a monolith and need to route traffic to multiple services, or an existing gateway setup is causing pain (config sprawl, latency, or vendor lock-in) and you want to know what else is out there.
The short answer: there's no single "best" gateway for every .NET Core setup. The right choice depends on whether you want a code-first .NET-native solution (YARP, Ocelot), a battle-tested standalone gateway (Kong, Traefik), or a managed cloud service (Azure API Management). Below is a practical breakdown of each, plus where an API layer like SubToAPI fits if part of your gateway's job is exposing AI features to client apps.
What an API gateway actually needs to do for microservices
Before comparing tools, be clear on the job description. A gateway sitting in front of .NET Core microservices typically needs to:
- Route requests to the correct backend service based on path, host, or header
- Terminate TLS and handle certificate rotation
- Authenticate and authorize requests before they hit your services
- Rate limit per client, API key, or route
- Aggregate or transform responses when a client needs data from multiple services
- Provide observability — request logs, latency metrics, error rates
- Handle retries and circuit breaking to prevent cascading failures
Some teams also need the gateway to normalize access to third-party APIs (LLMs, payment processors, etc.) so internal services don't each manage their own auth and rate limits for those dependencies.
YARP (Yet Another Reverse Proxy)
YARP is Microsoft's own reverse proxy toolkit, built to run inside a standard ASP.NET Core app. It's the most natural fit if your team wants a gateway written in the same stack as your services.
Strengths:
- Runs as a normal ASP.NET Core project — same deployment pipeline, same middleware model
- Highly configurable in code (
IProxyConfigProvider) or viaappsettings.json - Good performance; it's what Azure uses internally in some products
- Full control over load balancing, health checks, and transforms
Tradeoffs:
- You're building and maintaining a gateway, not buying one — features like a developer portal, plan management, or usage dashboards don't exist out of the box
- Less mature ecosystem for plugins compared to Kong
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();
YARP is the right pick when you want full control and your team is comfortable owning gateway code long-term.
Ocelot
Ocelot predates YARP and is still widely used in .NET Core microservices tutorials and production systems. It's configuration-driven (JSON files) rather than code-first.
Strengths:
- Simple to get started — routing, aggregation, and rate limiting are configured declaratively
- Built-in request aggregation for combining multiple downstream calls into one response
- Good documentation and a large base of existing examples
Tradeoffs:
- Development pace has slowed relative to YARP
- Performance is generally behind YARP in benchmarks
- Some advanced routing scenarios require custom middleware anyway
Ocelot remains a reasonable choice for smaller .NET Core microservice setups where you want something working quickly without writing custom proxy logic.
Kong and Traefik
If you'd rather not run a .NET-based gateway at all, Kong and Traefik are the standalone alternatives most teams compare.
Kong is plugin-driven (Lua/Go plugins), has strong rate limiting and auth plugins out of the box, and works fine in front of .NET Core services since it's language-agnostic — it just proxies HTTP.
Traefik integrates tightly with container orchestration (Docker, Kubernetes) and auto-discovers services via labels, which reduces manual route configuration.
Tradeoffs for both:
- Extra infrastructure to run and monitor, separate from your .NET deployment pipeline
- Plugin ecosystems are powerful but add operational complexity
- Team needs to learn a second config language/model outside C#
These make sense when your infrastructure is already polyglot or container-native and you don't want gateway logic tied to .NET release cycles.
Azure API Management (APIM)
For teams already on Azure, APIM is the managed option: no infrastructure to run, built-in developer portal, policy-based transforms, and native integration with Azure AD for auth.
Tradeoffs:
- Cost scales with tier and can get expensive at higher throughput
- Policy XML for request/response transforms has a learning curve
- Less flexible than code-first options for complex custom routing logic
APIM is a strong default if you're Azure-committed and want to avoid managing gateway infrastructure yourself.
Where SubToAPI fits alongside your gateway
None of the above tools are built to manage access to AI model APIs specifically. If your .NET Core microservices need to call Claude — for summarization, classification, or chat features — you still have to handle API keys, streaming responses, tool use, and per-team usage tracking somewhere.
SubToAPI turns your existing Claude access into a clean HTTPS API with its own scoped keys (sub_live_...), streaming support, and usage metadata per key — so your gateway (YARP, Kong, whatever you pick) can route /ai/* traffic to SubToAPI the same way it routes to any other internal service, without your .NET services each managing Claude auth and rate limits individually.
const res = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-3-5-sonnet",
messages: [{ role: "user", content: "Summarize this ticket" }]
})
});
Check the pricing page for Solo, Team, and Scale plans, or start with the quickstart to see the request/response shape before wiring it behind your gateway.
Making the call
For most .NET Core microservice teams, the practical shortlist is:
- YARP if you want a code-first, .NET-native gateway you fully control
- Ocelot if you want something declarative and quick to stand up
- Kong or Traefik if your infrastructure is already container/polyglot-first
- Azure APIM if you're Azure-committed and want a managed service
Whichever you pick, keep AI API access (auth, streaming, usage tracking) as a separate concern routed through the gateway rather than duplicated across services.
FAQ
Is YARP better than Ocelot for .NET Core microservices? YARP generally performs better and is Microsoft's actively developed option, but Ocelot's declarative config and built-in aggregation make it faster to set up for smaller projects.
Do I need a separate gateway if I'm using Kubernetes? Not necessarily — an Ingress controller like Traefik can act as your gateway, but many teams still add an API-level gateway (YARP, Kong) for auth and rate limiting logic that Ingress doesn't handle well.
Can I use SubToAPI behind my existing .NET Core gateway? Yes — SubToAPI exposes a standard HTTPS API, so your gateway can route to it like any other backend; see the docs for the request format and streaming details.