Skip to content

Instantly share code, notes, and snippets.

@russau
Created March 14, 2021 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russau/9cb231039f3d066b3ae49f03f67a3104 to your computer and use it in GitHub Desktop.
Save russau/9cb231039f3d066b3ae49f03f67a3104 to your computer and use it in GitHub Desktop.
.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