Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created December 4, 2016 20:32
Show Gist options
  • Save guitarrapc/5bfb764f2efbc1d7441f9ad6eb901f94 to your computer and use it in GitHub Desktop.
Save guitarrapc/5bfb764f2efbc1d7441f9ad6eb901f94 to your computer and use it in GitHub Desktop.
async / await with AWS Lambda
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using Amazon.Lambda.Serialization;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializerAttribute(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace SimpleAsyncFunction
{
public class Function
{
/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public async Task<string> FunctionHandlerAsync(string input, ILambdaContext context)
{
// You can check where these log will be written with LogGroup or StreamName in ILambdaContext
context.Logger.LogLine($"Logs will be write to following. {nameof(context.LogGroupName)} : {context.LogGroupName}, {nameof(context.LogStreamName)} : {context.LogStreamName}");
return input.ToUpper();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment