Skip to content

Instantly share code, notes, and snippets.

@russau
Created Mar 14, 2021
Embed
What would you like to do?
.NET debugging lambda
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
//[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace Debugging
{
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 Stream FunctionHandler(System.IO.Stream input, ILambdaContext context)
{
string result;
using (var memoryStream = new MemoryStream())
{
input.CopyTo(memoryStream);
byte[] arr = memoryStream.ToArray();
result = BitConverter.ToString(arr);
}
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(result));
return ms;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment