Git Product home page Git Product logo

aws-lambda-dotnet's Introduction

AWS Lambda & .NET

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/600px-AWS_Lambda_logo.svg.png

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/440px-Microsoft_.NET_logo.png

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/docker.png

All things we need to deploy .NET 5 AWS Lambda Support with Container Images!

AWS provides many resources about Lambda function and how to run it with .NET. However, I see it is quite obsolete and not very clear enough for newcomers. That's why I create this place to put all things I have gone through.

Source Code Structure

  • Lambda.Dotnet
    • A very simple project that we can write code and deploy it on AWS Lambda
  • Lambda.Dotnet.Mediator
    • Similar to Lambda.Dotnet. However, this project has an implementation of MediatR
  • Lambda.Tests
    • Help us to test the function locally before deploying to AWS Lambda

Configuration

We use appsetting.json as a normal .NET application. During testing time, we can manipulate Environment Variables via Environment.SetEnvironmentVariable

Docker

Currently, we use .NET 5 for the whole solution but we still can change it to any other .NET version. We even can build a custom Docker image as well.

  • In Dockerfile, we have COPY ["nuget.config", "."] to support a private package repository.
  • In case you need to run the code with .NET 6 which is not supported yet by AWS. Please let me know.

Deployment

We need to create a Lambda function with the Container image option.

  • Container image, it is a lambda function option to create a function that allows running Docker in it

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/Untitled.png

Image configuration - CMD

To let the Lambda function know which .NET function needs to be called when the lambda function event occurred, we have to correct ENTRYPOINT by updating CMD:

  • FunctionHandler

    Lambda.Dotnet::Lambda.Dotnet.Program::FunctionHandler
    Lambda.Dotnet.Mediator::Lambda.Dotnet.Mediator.Program::FunctionHandler
  • ScheduledEventHandler

    Lambda.Dotnet::Lambda.Dotnet.Program::ScheduledEventHandler
    Lambda.Dotnet.Mediator::Lambda.Dotnet.Mediator.Program::ScheduledEventHandler
  • ApiGatewateHandler

Lambda.Dotnet::Lambda.Dotnet.Program::ApiGatewateHandler
Lambda.Dotnet.Mediator::Lambda.Dotnet.Mediator.Program::ApiGatewateHandler

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/Untitled%201.png

AWS%20Lambda%20&%20NET%20cfb8e4348edf4e42b67a0dc558e3a080/Untitled%202.png

References

There are some other resources from AWS that you might want to check out

aws-lambda-dotnet's People

Contributors

minhhieugma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.