Create a gist now

Instantly share code, notes, and snippets.

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