ASP.Net Core API Gateway - Ocelot API Microservice

Microservices Tutorial Playlist Link: • What are Microservices...
In this video we explains about ASP.Net Core API Gateway and how to create an Ocelot API Microservice. We also explains the Ocelot API Gateway implementation in a Blazor Web Application. From this video you'll get an idea of how to implement Ocelot API Gateway in any .Net Core Applicaitons.
.Net Blazor Tutorial Playlist link:
• Blazor Tutorial - Begi...
Ocelot is a .NET API Gateway. This project is aimed at people using .NET running a micro services / service oriented architecture that need a unified point of entry into their system. However it will work with anything that speaks HTTP and run on any platform that ASP.NET Core supports. Ocelot is a bunch of middlewares in a specific order.
Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is retrieved as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features!
There are two sections in the Ocelot API Gateway configuration. An array of Routes and a GlobalConfiguration. The Routes are the objects that tell Ocelot API Gateway, how to treat an upstream request [Ocelot API Upstream]. The Global configuration allows overrides of ReRoute specific settings. It's useful if you don't want to manage lots of Route specific settings.
The main functionality of an Ocelot API Gateway is to take incoming HTTP requests and forward them on to a downstream service [Ocelot API Downstream], currently as another HTTP request. Ocelot's describes the routing of one request to another as a Route.
The DownstreamPathTemplate, Scheme, and DownstreamHostAndPorts make the internal microservice URL that this request will be forwarded to. The port is the internal port used by the service. When using containers, the port specified at its dockerfile.
The Host is a service name that depends on the service name resolution you are using. When using docker-compose, the services names are provided by the Docker Host, which is using the service names provided in the docker-compose files.
DownstreamHostAndPorts is an array that contains the host and port of any downstream services that you wish to forward requests to. Usually this configuration will just contain one entry but sometimes you might want to load balance requests to your downstream services and Ocelot lets you add more than one entry and then select a load balancer. But if using Azure and any orchestrator it is probably a better idea to load balance with the cloud and orchestrator infrastructure.
The UpstreamPathTemplate is the URL that Ocelot will use to identify which DownstreamPathTemplate to use for a given request from the client. Finally, the UpstreamHttpMethod is used so Ocelot can distinguish between different requests (GET, POST, PUT) to the same URL.
What is Docker Compose?
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.
Docker for .Net Core:
.NET Core can easily run in a Docker container. Containers provide a lightweight way to isolate your application from the rest of the host system, sharing just the kernel, and using resources given to your application. Learn how to use docker for .Net Core and deploy .Net Core to Docker.
.NET Core images
Official .NET Core Docker images are published to the Microsoft Container Registry (MCR) and are discoverable at the Microsoft .NET Core Docker Hub repository. Each repository contains images for different combinations of the .NET (SDK or Runtime) and OS that you can use.
Microsoft provides images that are tailored for specific scenarios. For example, the ASP.NET Core repository provides images that are built for running ASP.NET Core apps in production.
Video Chapters:
0:00 - Video Summary
2:07 - Ocelot API Gateway Development
12:25 - Adding Docker Orchestration Support
13:47 - Ocelot API Gateway Testing with Postman
16:21 - Ocelot API Gateway Implementation
#codingdroplets #microservices #apigateway #microservicestutorial #microservice #docker #dotnet6 #dotnet5 #dotnetcore #aspnetcore

Пікірлер: 52

  • @CodingDroplets
    @CodingDroplets2 жыл бұрын

    ⭐ Join Us on Patreon: www.patreon.com/CodingDroplets 🔗Microservice Architecture Playlist: Microservices Tutorial Playlist Link: kzread.info/dash/bejne/mYR90M2Fc8nHnKg.html 🔗Blazor Tutorial Playlist link: kzread.info/head/PLzewa6pjbr3IQEUfNiK2SROQC1NuKl6PV

  • @kamalrkumar
    @kamalrkumar10 ай бұрын

    Really neatly explained and good for the initial leaners...

  • @CodingDroplets

    @CodingDroplets

    10 ай бұрын

    Thank you for your feedback! Glad to hear that.

  • @imamarifhadipramono7788
    @imamarifhadipramono77886 ай бұрын

    Thank you for the explanation! It's very clear

  • @CodingDroplets

    @CodingDroplets

    6 ай бұрын

    You're very welcome! I'm delighted to hear that.

  • @benli7348
    @benli7348 Жыл бұрын

    very useful IT course, thank you for your leading us

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Thank you for watching the tutorial and for your kind words. I'm glad you found it useful!

  • @deepakgupta5733
    @deepakgupta573311 күн бұрын

    Awesome!!! ❤

  • @CodingDroplets

    @CodingDroplets

    9 күн бұрын

    Thank You!

  • @Yuyu-.-
    @Yuyu-.-6 ай бұрын

    Thanks for your sharing! ❤

  • @CodingDroplets

    @CodingDroplets

    6 ай бұрын

    You are so welcome!

  • @subhakantaparida7908
    @subhakantaparida790811 ай бұрын

    Perfect video thanks

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    Thank you for your kind words! Glad to hear that.

  • @DavidDanosTech
    @DavidDanosTech11 ай бұрын

    Perfect tutorial. Thnx a lot !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    You're welcome!❤

  • @kabsngandu8162
    @kabsngandu81624 ай бұрын

    Great video!

  • @CodingDroplets

    @CodingDroplets

    4 ай бұрын

    Thank You!

  • @sergeymigel4680
    @sergeymigel46803 ай бұрын

    Cool! Thanks

  • @CodingDroplets

    @CodingDroplets

    3 ай бұрын

    You are welcome!

  • @juhairahamed5342
    @juhairahamed53424 ай бұрын

    Thanks

  • @CodingDroplets

    @CodingDroplets

    4 ай бұрын

    Welcome

  • @rajank7200
    @rajank7200 Жыл бұрын

    Hello Sir, if how to configure multiple input parameter in some endpoint using ocelot

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    I think you are looking for adding multiple parameters in Route attribute in Web API. It can be done as below. [Route("MethodName/{parameter1}/{parameter2}")]

  • @joebrady9829
    @joebrady98293 ай бұрын

    Awesome series! I've learned so much from these videos so far. I cloned your repo and upgraded a subset of the solution (frontend, apigateway and the customer api and db) to .NET Core 8. Do you want me to submit a pull request?

  • @CodingDroplets

    @CodingDroplets

    3 ай бұрын

    Thank you for your kind words and for taking the initiative to upgrade the solution to .NET Core 8! I'm glad to hear that you found the series helpful. Submitting a pull request with the upgraded solution would be greatly appreciated! Once again, thank you for your contribution, and I look forward to reviewing your pull request!

  • @joebrady9829

    @joebrady9829

    3 ай бұрын

    @@CodingDropletsI created the pull request, I tested customers and products but not really sure how the order ui is supposed to work. It threw a json error but it could just be user error

  • @ali-de3my
    @ali-de3my10 ай бұрын

    Wow, such a helpful video. I have a question, when I stopped my vs, the docker couldn't response. How can I publish the solution?

  • @CodingDroplets

    @CodingDroplets

    10 ай бұрын

    Thank you for your positive feedback! To ensure your Docker container remains responsive after stopping Visual Studio, you'll need to publish your solution independently. Publish your app, build a Docker image, and run a container. This ensures your app is self-contained and doesn't rely on the development server.

  • @DeepakKumar-jg6mx
    @DeepakKumar-jg6mx Жыл бұрын

    Dear Sir, It is very useful video for basic learner. But I have a question, if I have more than one action in a controller and all are post method with different name then how to define it in Ocelot? Ex: [HttpPost][Route("CustomerList")], [HttpPost][Route("AddCustomer")], [HttpPost][Route("EditCustomer")], [HttpPost][Route("CustomerById")], [HttpPost][Route("deleteCustomer")] etc. Sorry sir, but I tried to resolve but did not get success. Plz help me. Thanks

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    You must add the url routing configuration in ocelot.json file.

  • @brayanyesidcanonrodriguez5186
    @brayanyesidcanonrodriguez5186 Жыл бұрын

    hello bro, with this same API gateway using ocelot, can I connect from a Django microservice?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Ocelot API Gateway is just routing the requests to different URLs based on the configuration we provided. You should be able to provide your Django url as well. I haven't tested it yet.

  • @brayanyesidcanonrodriguez5186

    @brayanyesidcanonrodriguez5186

    Жыл бұрын

    thank you very much brother, i will try it

  • @shwetayadav3238
    @shwetayadav323811 ай бұрын

    Hello, Can we do this project without using docker or it is mandatory to use docker with microservices Architecture.

  • @CodingDroplets

    @CodingDroplets

    11 ай бұрын

    Thank you for watching the video and for your question! We appreciate your curiosity about the project and its requirements. Using Docker with microservices architecture is not mandatory, but it offers several advantages that make it a popular choice for managing microservices-based applications. Docker can simplify the deployment and management of microservices. If you prefer not to use Docker, you can still follow the tutorial and set up the Ocelot API Gateway with your microservices using other deployment approaches.

  • @shwetayadav3238

    @shwetayadav3238

    11 ай бұрын

    @@CodingDroplets Thank You for clearing my doubt. I have one more issue. Actually, my APIGateway project is not working when I run the project it showing 404 error page is not found. could you please help me how can I solve this problem.

  • @creamcs
    @creamcs Жыл бұрын

    Do you know why i have CORS error only on Gateway but not on the Services?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Do you know how to enable CORS? Then obviously you'ld know why it that happened..

  • @creamcs

    @creamcs

    Жыл бұрын

    @@CodingDroplets I enabled the CORS and its fine now, thanks for reply

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Great! Thank You...

  • @andrw8946
    @andrw8946 Жыл бұрын

    Can we use Ocelot only for Authentication handling?

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Ocelot is an API Gateway with which you can route requests to different API services. It allows you to create a single endpoint from which all the services can be accessed.

  • @andrw8946

    @andrw8946

    Жыл бұрын

    @@CodingDroplets Thanks to your channel I can build my own API Gateway. Btw can I ask you one more: how to add multiple roles in in the claim check in Ocelot? I want it to check if the user is MasterAdmin OR Admin. If so - proceed. But if my token only contains roles: admin only, the authorization will not work.

  • @vcstudenttest3072
    @vcstudenttest3072 Жыл бұрын

    How authorizations work multiple roles, do we need only administrator omly

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    We can seperate multiple roles using comma in Authorize attribute. It is explained in the below video. kzread.info/dash/bejne/gmaj1cicpMyuccY.html

  • @akashgupta2366
    @akashgupta23662 жыл бұрын

    Can you please share git repo.

  • @CodingDroplets

    @CodingDroplets

    2 жыл бұрын

    github.com/codingdroplets/DemoMicroserviceSolution

  • @akashgupta2366

    @akashgupta2366

    2 жыл бұрын

    @@CodingDroplets Great thanks

  • @CodingDroplets

    @CodingDroplets

    2 жыл бұрын

    You are most welcome!

  • @matt.604
    @matt.604 Жыл бұрын

    Ocelot is now a dormant/dead project.

  • @CodingDroplets

    @CodingDroplets

    Жыл бұрын

    Planning to do a video on envoy api gateway

  • @yander5521

    @yander5521

    Жыл бұрын

    @@CodingDroplets great!