DEPENDENCY INJECTION Lambda | Lambda Annotations Framework | .NET ON AWS | Serverless | Amazon

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 17

  • @BrunoLeonidio
    @BrunoLeonidio Рік тому

    Dude, ur video is amazing! Ur explained everything so smoothly, in a way that as long as u speak, u keep incrementally expanding examples, showing how everything works and proving ur point .
    Congratz, dude. One more sub !

    • @RahulNath
      @RahulNath  Рік тому

      Wow thank you Bruno for your kind words. This is exactly what I aim to achieve with each of my videos. Hope you are enjoying the playlist bit.ly/aws-net-series

  • @emanuelcordovamontiel1017
    @emanuelcordovamontiel1017 7 місяців тому

    Do you recommend Singleton or Transient with repository class that work with data?

  • @arupmaitra88
    @arupmaitra88 Рік тому

    Great video and very much clear. Do you have any plan to make some video on how to deploy .NET Core WEB API into AWS EKS and scale accordingly ?

  • @gabrieloliveira5440
    @gabrieloliveira5440 9 місяців тому

    Hi Rahul, great video! You have helped alot throughout the last 6 months or so. I am having an issue where my lambda function works locally but it doesn't work on the aws lambda section. The error I'm getting is 'Reason: No parameterless constructor defined.' It seems it's not looking for the serverless.template file as an entry point and instead is trying to instantiate the 'Function' class (which is where my Function Handler is). i don't have a paremeterless constructor because I'm injecting my dependencies there.

    • @RahulNath
      @RahulNath  9 місяців тому +1

      Hey Gabriel Glad you are liking the content. Are you using the Lambda Annotations framework and have setup the Startup class etc appropriately? The entry point might be pointing to the actual class instead of the auto-generated class name that the annotations fwk generates. You can see in the example here that the entry point is a generated class. github.com/rahulpnath/youtube-samples/blob/main/LambdaAnnotationSample/LambdaAnnotationSample.FromScratch/serverless.template
      Let me know if that helps - if not you can reach me on email with more details and probably a demo app (details in About page)

    • @gabrieloliveira5440
      @gabrieloliveira5440 9 місяців тому

      ​@@RahulNath Thanks for the response. I am currently utilizing the lambda annotations framework and have configured both the startup class and function handler functions with the appropriate annotations. For local testing, I'm employing the Test Mock Lambda tool, which seamlessly works with injected services. Upon inspecting the .ddl file utilized by the AWS console using dotPeek, I observed that it mirrors the files generated locally in the bin/debug folder, including the presence of the serverless.template file accurately referencing the generated class serving as an entry point.
      My suspicion arises from the possibility that my company utilizes Terraform to orchestrate the AWS cloud infrastructure. Within the Terraform module for Lambda, they specify the handler. In this context, the handler points directly to the actual class, resembling something like: MyProduct.Functions.Submission::MyProduct.Functions.Submission.Function::FunctionHandler. I speculate that if I were to request a modification of the handler to reference the generated class defined in the serverless.template, akin to: MyProduct.Functions.Submission::MyProduct.Functions.Success.Function_FunctionHandler_Generated::FunctionHandler, it would likely function as expected. This assumption aligns with my understanding that the true entry point is the function inside the _Generated.cs file, defined in the serverless.template file. Correct me If I'm wrong regarding the true entry point.
      Regarding your example showcased in the video, subsequent to integrating your FromScratch project with lambda annotations, does the handler in the Lambda section of the AWS console alter to: LambdaAnnotationSample.FromScratch::LambdaAnnotationSample.FromScratch.Function_MathPlus_Generated::MathPlus? In your Lambda annotations video, before integrating with lambda annotationjs, it is set to -> LambdaAnnotationSample.BeforeAnnotations::LambdaAnnotationSample.BeforeAnnotations.Function::MathPlus.
      The video in question is this one: ua-cam.com/video/qWxjCkqX_lM/v-deo.html, at exactly the 3 minute mark.

    • @gabrieloliveira5440
      @gabrieloliveira5440 9 місяців тому

      ​@RahulNath I missed this but at the 16:29 minute mark in the current video, it did in fact change the handler to the generated file LambdaAnnotationsSample.FromScratch::LambdaAnnotationsSample.FromScratch.Function::MathPlus_Generated::MathPlus. I will request this change in the handler of the terraform modules. Thank you for this, I have learned alot from you. My sincerest respect goes out to you.

    • @RahulNath
      @RahulNath  9 місяців тому

      Great let me know how this goes and hope you are able to resolve your problem. Do let me know if you have any topic suggestions.

  • @mahesh_rcb
    @mahesh_rcb Рік тому

    How can we work with EF and Lamda?
    In this case will the dbcontext be singleton if injected in function constructor or an interface

    • @kithandle
      @kithandle Місяць тому

      Mahesh. Did you get this to work?
      I have to do something similar. I need to inject a repository. I think I just need to manually setup all dependencies and nested dependencies for the 2 services I need.
      Haven’t worked with Lambdas but since they’re separate and their own context, we have to setup all services manually to be used for Dependency Injection.
      Since I’m referencing code in another project within the solution which has its own configuration and services. I was thinking it would work automatically. But that doesn’t seem like the case.

    • @mahesh_rcb
      @mahesh_rcb Місяць тому +1

      @@kithandle
      Yes I did , u can register with DI and use DBcontext same as other api code
      But lamda have some lifetime , which can reuse the same instance
      So be sure to use transient scope or data always and do a check for data duplication
      Becz in my case my lambda is triggered from the event bridge rule and sometimes it creates duplicate data.

    • @mahesh_rcb
      @mahesh_rcb Місяць тому

      @@kithandle
      U can use DI for it , no need to create manually

    • @kithandle
      @kithandle Місяць тому

      @@mahesh_rcb good to know. I’ll keep that in mind.
      For my lambda I’m planning to have it be triggered by an SQS event. So I may need to subscribe to that particular event for the lambda to run.
      But working thru the DI issues now. Seems like I’m having to manually wire up the services in the Lambda project somewhat similar to what is already done in the API project.
      I was hoping bc lambda project references another project that then references the API that it would know to get those services automatically.
      But that doesn’t seem to be the case.
      Unless I’m just doing something incorrectly.
      So right now just manually adding dependent services in Lambda. Then deploying and invoking to see the error. Then repeat til I get them all setup.
      Hopefully that works.
      But based on what you’re saying. I do NOT need to setup services manually for Lambda? If so how did you do it?
      Thanks

    • @mahesh_rcb
      @mahesh_rcb Місяць тому

      @@kithandle In the function constructor u can initialise or have abstract base class which does the DI container creation , there are different ways u could do
      U can find samples code in stack overflow
      If u have few service or class to be used DI canbe a over use
      If u need different service or instances in different places di is best

  • @MarianoGomezBidondo
    @MarianoGomezBidondo Рік тому

    Maybe someday you can make a video on how to use different environments (or Stages, development or production in example) and how to deploy them using Lambda Annotions Framework.

    • @RahulNath
      @RahulNath  Рік тому

      Thank you Mariano for the feedback. What would you like to see in that video? Anything you are particularly stuck with?