@page "/" @using System.Threading; @using Amazon.Lambda.TestTool.Runtime; @using Amazon.Lambda.TestTool.SampleRequests; @inject LocalLambdaOptions LambdaOptions @inject IModalService Modal

@Constants.PRODUCT_NAME

Run .NET Lambda function code inside this tool. IDEs can attach their debuggers to this tool and step through the Lambda code.

If you are developing .NET Lambda function using custom runtimes or C# top level statements that use the Amazon.Lambda.RuntimeSupport NuGet package the Executable Assembly page should be used to test the function.

Tip: If a Lambda function using the default serializer, Amazon.Lambda.Serialization.Json, is deployed with the environment variable LAMBDA_NET_SERIALIZER_DEBUG set to true the JSON input for the Lambda function will be written to CloudWatch Logs. The captured JSON can then be used in this tool to step through the code.


The area below shows the result returned by your function execution.
@FunctionResponse

The area below shows the logging calls in your code.
@FunctionLogs
@code { string ResultsPanelStyle { get; set; } = "display: none;"; string FunctionResponseStyle { get; set; } = Constants.ResponseSuccessStyle; FunctionPickerComponent FunctionPicker { get; set; } public IDictionary> SampleRequests { get; set; } public string FunctionInput { get; set; } public string FunctionResponse { get; set; } public string FunctionLogs { get; set; } string _selectedSampleRequestName; string SelectedSampleRequestName { get => this._selectedSampleRequestName; set { this._selectedSampleRequestName = value; this.FunctionInput = SampleRequestManager.GetRequest(this._selectedSampleRequestName); this.StateHasChanged(); } } SampleRequestManager SampleRequestManager { get; set; } protected override void OnInitialized() { this.SampleRequestManager = new SampleRequestManager(LambdaOptions.GetPreferenceDirectory(false)); this.SampleRequests = SampleRequestManager.GetSampleRequests(); } void OnSaveRequestClick() { var parameters = new ModalParameters(); parameters.Add(SaveRequestDialog.PARAMETER_NAME_REQUEST_BODY, this.FunctionInput); if(SampleRequestManager.TryDetermineSampleRequestName(SelectedSampleRequestName, out var sampleRequestName)) { parameters.Add(SaveRequestDialog.PARAMETER_NAME_CURRENT_NAME, sampleRequestName); } Modal.OnClose += OnSaveRequestClosed; Modal.Show("Save Request", parameters); } void OnSaveRequestClosed(ModalResult modalResult) { Modal.OnClose -= OnSaveRequestClosed; if (modalResult.Cancelled) { return; } this.SampleRequests = SampleRequestManager.GetSampleRequests(); this.SelectedSampleRequestName = modalResult.Data as string; this.StateHasChanged(); } void OnExecuteClick() { ExecutionResponse response = null; var ts = new ThreadStart(() => { var function = this.LambdaOptions.LoadLambdaFuntion(FunctionPicker.ConfigFile, FunctionPicker.FunctionHandler); var request = new ExecutionRequest() { Function = function, AWSProfile = FunctionPicker.AWSProfile, AWSRegion = FunctionPicker.AWSRegion, Payload = this.FunctionInput }; response = this.LambdaOptions.LambdaRuntime.ExecuteLambdaFunctionAsync(request).GetAwaiter().GetResult(); }); var thread = new Thread(ts); thread.Start(); thread.Join(); if (response.IsSuccess) { this.FunctionResponse = response.Response; this.FunctionResponseStyle = Constants.ResponseSuccessStyle; } else { this.FunctionResponse = response.Error; this.FunctionResponseStyle = Constants.ResponseErrorStyle; } this.FunctionLogs = response.Logs; ResultsPanelStyle = "display: block"; this.StateHasChanged(); } }