c# & aws lambda

Download C# & AWS Lambda

Post on 09-Apr-2017




5 download

Embed Size (px)


  • C# on AWS Lambda

    1 @phermens

  • About me

    Pat Hermens

    Father of two

    Based in Rotterdam

    Lead Developer at Coolblue

    Still have a soft-spot for VB6

    https://hermens.com.au/ 2



  • Every day a little more Dutch


  • A little bit of history

    4 @phermens

  • Launched in Nov 2014.5


  • C# support in Dec 2016.6


  • Officially only supports .NET Core.7


  • AWS was first of the major providers.8


  • They have an open-source SDKhttps://github.com/aws/aws-sdk-net/ 9



  • They also have a great dotnet repohttps://github.com/aws/aws-lambda-dotnet/ 10



  • & most of my tooling is from here11


  • Its Hello world time!

    12 @phermens

  • 13 @phermens

    Hello World! (including ILambdaContext)

  • Relatively simple configuration14


  • Wait, we need more than code!

    15 @phermens

  • 16 @phermens

    Set up an account

  • Install the CLI

    17 @phermens

  • 18 @phermens

  • 19 @phermens

    Regions? AZs?

  • 20 @phermens


  • 21 @phermens

    Required values can be set in code!

  • 22 @phermens

    or on the command line!

  • NOW its Hello world time!

    23 @phermens

  • 24 @phermens

    Hello World! (including ILambdaContext)

  • Deploying Hello-World

    25 @phermens

  • 26 @phermens

    Running deploy-function & invoke-function

  • Calling our Hello function

    27 @phermens

  • 28 @phermens

    We can use the Amazon NuGet package(s)

  • We can use AWS SNS29


  • We can use any webhook-type integration30


  • Creating a Hello-World-Caller

    31 @phermens

  • 32 @phermens

    Pretty straightforward using the SDK

  • Just F5 in VS Code!33


  • Larger architectures?

    34 @phermens

  • Our infra team had a fun exercise...35


  • CloudFormation - scripted infrastructure36


  • Normally looks like this...37


  • but can also look like this!38


  • Add trigger to your Lambda39


  • Pick your integration - whatever you want!40


  • Or just, deploy-serverless with the CLI41


  • AWS Serverless Application Modelhttp://github.com/awslabs/ 42



  • http://serverless.com/framework/docs/ 43



  • So, what does this mean for Coolblue?44


  • This makes it look simple!45


  • Lets recap some gotchas

    46 @phermens

  • 47 @phermens

    Timings can vary wildly!

  • Default values can bite you!48


  • Know your costs! 800,000 sec = 9.25 dayshttps://aws.amazon.com/lambda/pricing/ 49



  • Almost everything is case-sensitive!50


    PS> dotnet lambda deploy-function HelloWorld-EUWest# New Lambda function created

    PS> dotnet lambda invoke-function helloworld-euwest -p "Pat"# Error invoking Lambda function: Function not found: arn:aws:lambda:eu-west-1:955206359773:function:helloworld-euwest

  • ILambdaContext should ALWAYS be last51


    public string SayHi(ILambdaContext context, string name = "World"){

    // do something}

    RESPONSE: (only on invocation, after deployment){ "errorType": "LambdaException", "errorMessage":

    "Method 'SayHi' of type 'MyFirstLambdaFunction.HelloWorld' is not supported:the method has 2 parameters, but the second parameter is not of type'Amazon.Lambda.Core.ILambdaContext'."


  • Read the FAQs! https://aws.amazon.com/lambda/faqs/ 52


    Q: How are compute resources assigned to an AWS Lambda function?In the AWS Lambda resource model, you choose the amount of memory you want for your function, and are allocated proportional CPU power and other resources.

    For example, choosing 256MB of memory allocates approximately twice as much CPU power to your Lambda function as requesting 128MB of memory and half as much CPU power as choosing 512MB of memory. You can set your memory in 64MB increments from 128MB to 1.5GB.


  • Containers can be reused!https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/ 53



  • Handy links

    54 @phermens

    Tooling https://github.com/aws/aws-sdk-net/ https://github.com/aws/aws-lambda-dotnet/

    Documentation http://github.com/awslabs/ http://serverless.com/framework/docs/ https://aws.amazon.com/lambda/faqs/


  • https://aws.amazon.com/documentation/ 55



  • 56 @phermens

  • Thanks!

    57 @phermens

    Tonights demos are on GitHub (but theyre really nothing special!)




  • Thanks!

    58 @phermens