No video

How To Build an API Gateway for Microservices with YARP

  Рет қаралды 20,766

Milan Jovanović

Milan Jovanović

Күн бұрын

Пікірлер: 116
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Want to master Clean Architecture? Go here: bit.ly/3PupkOJ Want to unlock Modular Monoliths? Go here: bit.ly/3SXlzSt
@sekarcse
@sekarcse 7 ай бұрын
We can use Ocelot package for the same, Is it Yarp has more features than Ocelot? Which one is better?
@qaweeysoetan7794
@qaweeysoetan7794 7 ай бұрын
i have done that already i also follow you on LInkdin
@mostafachronic1874
@mostafachronic1874 3 ай бұрын
Hello, explain validation and authentication in microservices using JWT.
@evgeniilewicki5874
@evgeniilewicki5874 2 ай бұрын
How nice it is to watch when a person has good diction and understanding of the issue. He speaks competently. Thank you very much for your work.
@MilanJovanovicTech
@MilanJovanovicTech 2 ай бұрын
Thanks a lot, I appreciate that! :)
@sekarcse
@sekarcse 7 ай бұрын
Hi Milan, Would you be able to include a video featuring Ocelot and Yarp? Both are useful tools, with Yarp being more lightweight and Ocelot offering more features. I would recommend using them for a small project that involves handling authentication and authorization in a Gateway and passing headers to the downstream API.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Planning on it!
@allwinantofranklin895
@allwinantofranklin895 7 ай бұрын
@@MilanJovanovicTech Waiting for it for a long time........!!!!!!!!!
@RicusNortje
@RicusNortje 7 ай бұрын
I did this at my previous company as well. What I love is that if you add auth middleware before you add the proxy it then authenticates the request before it passes it downstream. You can alos add minimal API endpoints and again map them before the proxy then that allows you to override specific endpoints if you need to (for example to map the model to a new contract) and then any other endpoints on that path you did not override gets proxied.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Might make another video for Auth, could be useful
@PelFox
@PelFox 7 ай бұрын
How do you secure downstream APIs in that case, private networks? What if underlaying services also need details about the user's claims?
@RicusNortje
@RicusNortje 7 ай бұрын
​@PelFox We used service accounts so the gateway (YARP minimal API) would do a token exchange for delegated access and then use that JWT. That might not be the best for each use case but it suited us well. Otherwise, you can just proxy the JWT to the downstream then the downstream will also validate the token.
@yardeZ93
@yardeZ93 7 ай бұрын
Hi Milan thanks for the video, Can you talk about authentication and authorization options and implementations with reverse proxy? What are the best practices?
@sekarcse
@sekarcse 7 ай бұрын
Add middleware to handle authentication and pass the necessary headers to the Service (Actual API).
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Sure, that can be one of the next videos! 😁
@jameshancock
@jameshancock 7 ай бұрын
Would be awesome to see how this can integrate with kubernetes and also certificates including cert manager in kubernetes.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Found this for the time being: github.com/microsoft/reverse-proxy/blob/main/docs/docfx/articles/kubernetes-ingress.md
@antonmartyniuk
@antonmartyniuk 7 ай бұрын
I've successfully used Yarp in some of my smaller projects. On a bigger projects or projects with high traffic I've used Traefik and Envoy. They seem to work faster and can process pretty highload
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Did you not try YARP on those bigger projects?
@antonmartyniuk
@antonmartyniuk 7 ай бұрын
@@MilanJovanovicTech no. Traefik and Envoy are much more feature rich that we used. And we compared benchmarks of other people comparing these reverse proxies
@MirrorBoySkr
@MirrorBoySkr 7 күн бұрын
8:12 Transforms followed by {}. 8:29 - [] are used. Thats important!!!
@MilanJovanovicTech
@MilanJovanovicTech 7 күн бұрын
I make a typo here and there
@mad_t
@mad_t 7 ай бұрын
Interesting library. But I would like to see benchmarks YARP vs Nginx, because I don't want to reinvent the wheel
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Microsoft replaced Nginx on Azure App Service for a +80% throughput, I'll see what I can do for the benchmarks
@codeme8016
@codeme8016 7 ай бұрын
This was an easy to follow tutorial which is pretty rare on KZbin. Thank you very much. Would you also please mention what the use is?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
The use of YARP? Load balancing, gateways, reverse proxying. Here are the docs: microsoft.github.io/reverse-proxy/
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
I also wrote an article: www.milanjovanovic.tech/blog/implementing-an-api-gateway-for-microservices-with-yarp
@stonefish76
@stonefish76 6 ай бұрын
Great video Milan! I've wanted to play with yarp a while now but was intimidated by the time it would take to learn it. You make it seem easy here.
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Nope, YARP is too easy to use. Don't waste time and just start building something 😁
@JesperPDk
@JesperPDk 2 ай бұрын
Have u make a video about docker-compse, how i will add this? - I have try to follow u video but i cant found out how i add docker compose?
@MilanJovanovicTech
@MilanJovanovicTech 2 ай бұрын
Yes: kzbin.info/www/bejne/jYKpqWWjarqVb68
@JesperPDk
@JesperPDk 2 ай бұрын
@@MilanJovanovicTech Thanks for link.
@sauravbhatta5303
@sauravbhatta5303 7 ай бұрын
Great video on reverse proxy. When u scale an application to multiple instances, how does Yarp manages db call? There will be still one db for all instances of application.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
YARP doesn't call the DB at all, it just proxies the requests to the other services - which talk to the DB
@asdasdaa7063
@asdasdaa7063 5 ай бұрын
Milan, can you make a video covering how to use azure cosmos db sql api, with multiple cosmos db accounts/cosmosclient instances? Been something I've been trying to learn.
@MilanJovanovicTech
@MilanJovanovicTech 5 ай бұрын
I doubt it, since I don't work on Cosmos DB
@arghakhanra204
@arghakhanra204 7 ай бұрын
Great❤, looking for more Microservices related videos Milan 👌
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
More to come!
@arghakhanra204
@arghakhanra204 7 ай бұрын
@@MilanJovanovicTech could you cover more Microservices topic from Scratch? Like building a distributive application using Microservices? Would be looking for the same. 🙂
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
@@arghakhanra204 Planning to. This year is for distributed systems :)
@arghakhanra204
@arghakhanra204 7 ай бұрын
@@MilanJovanovicTech Great, looking for it soon 👌🙂
@alijamal7893
@alijamal7893 7 ай бұрын
great content as always Milan 👏👏👏
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Thanks a lot! :)
@Sara-po1jd
@Sara-po1jd 7 ай бұрын
nice video man! I wonder is it possible to configure Swagger on this api gateway (Yarp)
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
That'd be tricky. Let me look into if there's a good solution these days. I didn't find one a few years ago.
@hernanar3647
@hernanar3647 6 ай бұрын
The api gateway can redirect to the generated Swagger UI If you want to "merge" those files, by knowing the address of the API and the path of swagger.json (or yaml) file, you can show them in the api gateway as documents of the swagger UI if you configure a swagger endpoint :)
@IvanRicardoLopes
@IvanRicardoLopes 7 ай бұрын
Nice tutorial,.Can We have a video about How to build an API Gateway for Microservices with Ocelot?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Great suggestion!
@jefffiegel1758
@jefffiegel1758 6 ай бұрын
I know we can have Active health checks for the downstream endpoints... How can we get the output/status of those checks by querying YARP itself???
@MilanJovanovicTech
@MilanJovanovicTech 6 ай бұрын
Need to check, I'd start with YARP docs in the meantime
@sinanoral19
@sinanoral19 7 ай бұрын
There are 3 terms reverse proxy, api gateway and load balancer. I am confused. Can you explain the differences each of that three
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
- Proxy - server that hides internal servers from outside world - Gateway - basically the same as proxy, and you will usually see additional features added - LB - a proxy/gateway routing traffic between multiple API instances
@sinanoral19
@sinanoral19 7 ай бұрын
@@MilanJovanovicTech thank you so much
@user-bp4cw4qh8h
@user-bp4cw4qh8h 7 ай бұрын
is yarp suitable for large request per second for example 3000 reques per second?or we use from ocelot without it
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Microsoft is doing 1.9M RPS with YARP. I think it can handle that load :)
@antonmartyniuk
@antonmartyniuk 7 ай бұрын
Milan, what's your PC configuration and what's your monitors' sizes?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
24" monitors x2 AMD Ryzen 7 7700X NVidia GeForce RTX 3060 32GB RAM (DDR5)
@JustCode512
@JustCode512 7 ай бұрын
Thank you again.. 10/10
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
You're very welcome!
@mostafachronic1874
@mostafachronic1874 3 ай бұрын
Hello, explain validation and authentication in microservices using JWT.
@MilanJovanovicTech
@MilanJovanovicTech 3 ай бұрын
Will do
@PelFox
@PelFox 7 ай бұрын
When would you want this over something like Azure Apim?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Out of cloud, for example
@sinthonseng8981
@sinthonseng8981 Ай бұрын
Does .NET Aspire provide any native support for API gateway functionalities?
@MilanJovanovicTech
@MilanJovanovicTech Ай бұрын
I think they will probably add support for YARP
@regestea
@regestea 7 ай бұрын
so when we use api gateway we loose swagger document , is that ok ?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
You still have Swagger on the APIs
@vadimr5847
@vadimr5847 7 ай бұрын
Thank you, It works!
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
You're welcome!
@garyfirzon
@garyfirzon 7 ай бұрын
Thanks!
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Thank you very much for the support! 😊
@eugene5096
@eugene5096 7 ай бұрын
Hey Milan, are you posting some sample projects to your github ? As it contains a bit obsolete samples now.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Planning to post a Clean Architecture and Modular monolith template soon. Will be .NET 8, all the best practices, etc.
@eugene5096
@eugene5096 7 ай бұрын
​@@MilanJovanovicTechwow can't wait
@yugo6243
@yugo6243 7 ай бұрын
Thank you for great tutorial. Looking forward for an enhanced tutorial with Yarp as reverse proxy with authentication.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Great suggestion 👌
@Sara-po1jd
@Sara-po1jd 7 ай бұрын
I have a question regarding the authentication and authorization in the yarp, should it be at the gateway level or the microservices? I mean can we secure only the yarp requests without taking care of secuing the microservices since they are not exposed publically? if it is enough to do it on the Yarp level any idea on how we can do this on specific request and not the entire route?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Typically Gateway will also handle authentication. The services could be left out, if you keep them in a private (closed) network. But in most cases, you need to know who the current user is even in the microservices. So you'll still have some form of authentication, if only verifying the access token.
@Sara-po1jd
@Sara-po1jd 7 ай бұрын
@@MilanJovanovicTech yeah in our case we dont need to trace the user in the microservice. we only need to authenticate some CUD operations, do you have an idea on how can i secure some endpoints and not the entire route using Yarp? I cant find it in the Yarp documentation.
@maverickiy9366
@maverickiy9366 7 ай бұрын
That is great. But let's consider I want to deploy my services on AWS ECS, or Azure Container Apps, then how this YARP will function ? How Load balancing and high availability will work with ECS or Azure Container Apps with YARP?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
- YARP supports load balancing www.milanjovanovic.tech/blog/implementing-an-api-gateway-for-microservices-with-yarp - As for running in a HA setup, you can do a primary-secondary setup
@PelFox
@PelFox 7 ай бұрын
@@MilanJovanovicTech Link returns 404
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
@@PelFox YT picked up the ) in the end 😅
@JanKowalski-ld4ec
@JanKowalski-ld4ec 7 ай бұрын
Hello, Just wondering if you could publish some good advices about working with Excel || Word objects in c#. Would be great! Regards! JK
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
I doubt it (at least in the short term)
@JanKowalski-ld4ec
@JanKowalski-ld4ec 7 ай бұрын
@@MilanJovanovicTech For sure there are more hot topics ;) Just thought about it and yourself while working on current project. Best regards!
@ewgenbi
@ewgenbi 7 ай бұрын
What about websocket?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
microsoft.github.io/reverse-proxy/articles/websockets.html
@OldShoolGames
@OldShoolGames 7 ай бұрын
Does this work with signalr/blazor server in case of a high availability/replicated backend ?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
microsoft.github.io/reverse-proxy/articles/websockets.html
@OldShoolGames
@OldShoolGames 7 ай бұрын
@@MilanJovanovicTech Thank you Milan
@Cesar-qi2jb
@Cesar-qi2jb 7 ай бұрын
Is YARP just a reverse proxy? Can it be used as a Gateway too? I need to create a Backend For Front-end (BFF) and I need to combine data from different microservices.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Did I not use it as a Gateway in this video? I also covered load balancing: kzbin.info/www/bejne/ZoPEeWyenbR5ask
@Cesar-qi2jb
@Cesar-qi2jb 7 ай бұрын
@@MilanJovanovicTech Yes, you did. But how would you map (transform) two differentl endpoints into one?
@roberteru25
@roberteru25 7 ай бұрын
​@@Cesar-qi2jb Create an orchestrator service, then expose the service with grpc, then you can build response from the different APIs
@Cesar-qi2jb
@Cesar-qi2jb 7 ай бұрын
@@roberteru25 Thanks for the advise. We prefer sticking with REST (Swagger) for our microservices as these are also publicly exposed to partners. We just have the need to build more BFFs. We already have one for the main website but we are willing to build more for other use cases. I don't really know what would be the best approach for building a Back End For Front-end in .NET.
@qaweeysoetan7794
@qaweeysoetan7794 7 ай бұрын
Please can i get the github repo for dis to study more
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
github.com/m-jovanovic/yarp-api-gateway-sample
@Foodies-pv7ih
@Foodies-pv7ih 7 ай бұрын
What about authentication?
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Works with built-in Auth in ASP.NET Core
@user-bx2er2zx5u
@user-bx2er2zx5u 7 ай бұрын
How to forbid users to call your api's directly instead of using proxy?
@ByronScottJones
@ByronScottJones 7 ай бұрын
Generally you would only give the proxy an external IP and DNS record.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Network rules, you can close your APIs to the outside world, and only let them talk to the Proxy
@allannielsen4752
@allannielsen4752 2 ай бұрын
Hi at kzbin.info/www/bejne/i5rHhWqPjtpsbdUsi=cyo8An6JY--Z_h3H&t=659 you show the create (POST) however you don't show the CreatedAtUrl that is meant to be returned. Since the api doesn't know about the proxy it sets the api url not the proxy's public url. can you comment on that?
@MilanJovanovicTech
@MilanJovanovicTech 2 ай бұрын
You'd need to use the Forwarded URI to make it all work. Might cover that in a future video.
@marcobaccaro
@marcobaccaro 4 ай бұрын
Kids, please don't use this. API Management products exist for a reason (Azure APIM, AWS API Gateway, MuleSoft, Kong, Gravitee, Apigee...)
@MilanJovanovicTech
@MilanJovanovicTech 4 ай бұрын
If anything, it's good to understand the concepts behind these cloud services
@pigrebanto
@pigrebanto 7 ай бұрын
Nice but you speak at speed of light.
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
🤷‍♂️
@antonmartyniuk
@antonmartyniuk 7 ай бұрын
Turn the x2 speed off, lol
@Yago4341
@Yago4341 7 ай бұрын
I’m brazilian, not fluent in English, and i can understand his speak very well
@user-xm7sh3vw8o
@user-xm7sh3vw8o 7 ай бұрын
I've posted it before
@MilanJovanovicTech
@MilanJovanovicTech 7 ай бұрын
Where?
How To Build Loosely Coupled Microservices With MassTransit
23:01
Milan Jovanović
Рет қаралды 33 М.
How To Build a Load Balancer In .NET With YARP Reverse Proxy
11:33
Milan Jovanović
Рет қаралды 19 М.
Throwing Swords From My Blue Cybertruck
00:32
Mini Katana
Рет қаралды 10 МЛН
This Dumbbell Is Impossible To Lift!
01:00
Stokes Twins
Рет қаралды 42 МЛН
At the end of the video, deadpool did this #harleyquinn #deadpool3 #wolverin #shorts
00:15
Anastasyia Prichinina. Actress. Cosplayer.
Рет қаралды 15 МЛН
Unveiling my winning secret to defeating Maxim!😎| Free Fire Official
00:14
Garena Free Fire Global
Рет қаралды 16 МЛН
Microservices with Databases can be challenging...
20:52
Software Developer Diaries
Рет қаралды 27 М.
What is an API Gateway?
10:19
IBM Technology
Рет қаралды 308 М.
HTTP Polling vs SSE vs WebSocket vs WebHooks
22:22
ByteVigor
Рет қаралды 4,4 М.
7 Serilog Best Practices for Better Structured Logging
13:36
Milan Jovanović
Рет қаралды 24 М.
API Gateway vs Load Balancer vs Reverse Proxy: when to use what?
9:06
Software Developer Diaries
Рет қаралды 15 М.
Get Rid of Exceptions in Your Code With the Result Pattern
13:06
Milan Jovanović
Рет қаралды 49 М.
Reverse Proxy vs API Gateway vs Load Balancer
3:06
ByteByteGo
Рет қаралды 120 М.
Fix Your Controllers By Refactoring To Minimal APIs
14:56
Milan Jovanović
Рет қаралды 39 М.
API Gateway | Никита Радченко, Михаил Копылов
35:59
EPAM Moscow ITsubbotnik
Рет қаралды 9 М.
Throwing Swords From My Blue Cybertruck
00:32
Mini Katana
Рет қаралды 10 МЛН