[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
public string FunctionHandler(string input, ILambdaContext context) { return input?.ToUpper(); }
ASSEMBLY::TYPE::METHOD
using System; using System.Collections.Generic; using System.Linq; 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.Json.JsonSerializer))] namespace AWSLambda3 { 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 string FunctionHandler(string input, ILambdaContext context) { return input?.ToUpper(); } } }
Sr.No | 属性和描述 |
1 |
MemoryLimitInMB
这将提供为 AWS Lambda 函数配置的内存的详细信息
|
2 |
FunctionName
AWS Lambda 函数的名称
|
3 |
FunctionVersion
AWS Lambda 函数的版本
|
4 |
InvokedFunctionArn
ARN 用于调用此函数。
|
5 |
AwsRequestId
创建的 AWS 函数的 AWS 请求 ID
|
6 |
LogStreamName
Cloudwatch 日志流名称
|
7 |
LogGroupName
Cloudwatch 组名
|
8 |
ClientContext
与 AWS 移动开发工具包一起使用时有关客户端应用程序和设备的信息
|
9 |
Identity
与 AWS 移动开发工具包一起使用时有关亚马逊 cogbnito 身份的信息
|
10 |
RemainingTime
直到函数终止的剩余执行时间
|
11 |
Logger
与上下文关联的记录器
|
using System; using System.Collections.Generic; using System.Linq; 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.Json.JsonSerializer))] namespace AWSLambda6 { public class Function { /// <summary> /// </summary> /// <param name="input"></param> /// <param name="context"></param> /// <returns></returns> public void FunctionHandler(ILambdaContext context) { LambdaLogger.Log("Function name: " + context.FunctionName+"\n"); context.Logger.Log("RemainingTime: " + context.RemainingTime+"\n"); LambdaLogger.Log("LogGroupName: " + context.LogGroupName+"\n"); } } }
public void FunctionHandler(ILambdaContext context) { LambdaLogger.Log("Function name: " + context.FunctionName+"\n"); context.Logger.Log("RemainingTime: " + context.RemainingTime+"\n"); LambdaLogger.Log("LogGroupName: " + context.LogGroupName+"\n"); }
namespace example { public class AccountAlreadyExistsException : Exception { public AccountAlreadyExistsException(String message) : base(message) { } } } namespace example { public class Handler { public static void CreateAccount() { throw new AccountAlreadyExistsException("Error in AWS Lambda!"); } } }
{ "errorType": "LambdaException", "errorMessage": "Error in AWS Lambda!" }