title: Why is AWS Lambda failing to reach the FunctionHandler?
body: <p>I am:</p>
  <ol>
  <li>deploying a C# app to Lambda to the first time.</li>
  <li>using Mac so can't use the Visual Studio <a href="https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017" rel="nofollow noreferrer">AWS Toolkit Extension</a>.</li>
  <li>using C# .NET core 3.1.</li>
  <li>deploying using: <a href="https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-cli-publish.html" rel="nofollow noreferrer">dotnet lambda deploy-serverless</a></li>
  </ol>
  <p>The deployment seems to work without errors, the Lambda is visible in the AWS Console.</p>
  <p>When I test the Lambda from AWS Console log output is generated, some of which is from my C# code. Such as this line &quot;LambdaEntryPoint - init&quot;.</p>
  <p>However none of the log output in my handler (FunctionHandlerZ) is written to the log.</p>
  <p>I see this exception when I use the AWS Console Test facility:</p>
  <pre><code>{
    &quot;errorType&quot;: &quot;NullReferenceException&quot;,
    &quot;errorMessage&quot;: &quot;Object reference not set to an instance of an object.&quot;,
    &quot;stackTrace&quot;: [
      &quot;at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayProxyRequest apiGatewayRequest, ILambdaContext lambdaContext)&quot;,
      &quot;at Amazon.Lambda.AspNetCoreServer.AbstractAspNetCoreFunction`2.FunctionHandlerAsync(TREQUEST request, ILambdaContext lambdaContext)&quot;,
      &quot;at Amazon.Lambda.RuntimeSupport.HandlerWrapper.&lt;&gt;c__DisplayClass25_0`2.&lt;&lt;GetHandlerWrapper&gt;b__0&gt;d.MoveNext()&quot;,
      &quot;--- End of stack trace from previous location where exception was thrown ---&quot;,
      &quot;at Amazon.Lambda.RuntimeSupport.LambdaBootstrap.InvokeOnceAsync(CancellationToken cancellationToken)&quot;
    ]
  }
  </code></pre>
  <p>LambdaEntryPoint.cs</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Hosting;
  using System.IO;
  using Amazon.Lambda.Core;
  
  [assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
  
  namespace aspDemo3B
  {
      public class LambdaEntryPoint :
          // When using an ELB's Application Load Balancer as the event source change 
          // the base class to Amazon.Lambda.AspNetCoreServer.ApplicationLoadBalancerFunction
          Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
      {
          /// &lt;summary&gt;
          /// The builder has configuration, logging and Amazon API Gateway already configured. The startup class
          /// needs to be configured in this method using the UseStartup&lt;&gt;() method.
          /// &lt;/summary&gt;
          /// &lt;param name=&quot;builder&quot;&gt;&lt;/param&gt;
          protected override void Init(IWebHostBuilder builder)
          {
              Console.WriteLine(&quot;LambdaEntryPoint - init&quot;);
  
              builder
                  .UseStartup&lt;Startup&gt;();
          }
  
          public string FunctionHandlerZ(string input, ILambdaContext context)
          {
              Console.WriteLine(&quot;FunctionHandlerZ&quot;);
              Console.WriteLine($&quot;Calling function name: {context.FunctionName}\\n&quot;);
              return input?.ToUpper();
          }
      }
  }
  </code></pre>
  <p>serverless.template</p>
  <pre><code>{
    &quot;AWSTemplateFormatVersion&quot;: &quot;2010-09-09&quot;,
    &quot;Transform&quot;: &quot;AWS::Serverless-2016-10-31&quot;,
    &quot;Description&quot;: &quot;An AWS Serverless Application that uses the ASP.NET Core framework running in Amazon Lambda.&quot;,
    &quot;Parameters&quot;: {},
    &quot;Conditions&quot;: {},
    &quot;Resources&quot;: {
      &quot;AspNetCoreFunction&quot;: {
        &quot;Type&quot;: &quot;AWS::Serverless::Function&quot;,
        &quot;Properties&quot;: {
          &quot;Handler&quot;: &quot;aspDemo3B::aspDemo3B.LambdaEntryPoint:FunctionHandlerZ&quot;,
          &quot;Runtime&quot;: &quot;dotnetcore3.1&quot;,
          &quot;CodeUri&quot;: &quot;&quot;,
          &quot;MemorySize&quot;: 256,
          &quot;Timeout&quot;: 30,
          &quot;Role&quot;: null,
          &quot;Policies&quot;: [
            &quot;AWSLambdaFullAccess&quot;
          ],
          &quot;Environment&quot;: {
            &quot;Variables&quot;: {
              &quot;LAMBDA_NET_SERIALIZER_DEBUG&quot;: &quot;true&quot;
            }
          },
          &quot;Events&quot;: {
            &quot;ProxyResource&quot;: {
              &quot;Type&quot;: &quot;Api&quot;,
              &quot;Properties&quot;: {
                &quot;Path&quot;: &quot;/{proxy+}&quot;,
                &quot;Method&quot;: &quot;ANY&quot;
              }
            },
            &quot;RootResource&quot;: {
              &quot;Type&quot;: &quot;Api&quot;,
              &quot;Properties&quot;: {
                &quot;Path&quot;: &quot;/&quot;,
                &quot;Method&quot;: &quot;ANY&quot;
              }
            }
          }
        }
      }
    },
    &quot;Outputs&quot;: {
      &quot;ApiURL&quot;: {
        &quot;Description&quot;: &quot;API endpoint URL for Prod environment&quot;,
        &quot;Value&quot;: {
          &quot;Fn::Sub&quot;: &quot;https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/&quot;
        }
      }
    }
  }
  </code></pre>
  <p>I am happy to start from scratch with a simple helloWorld style Lambda that:</p>
  <ol>
  <li>Does not require <a href="https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017" rel="nofollow noreferrer">AWS Toolkit Extension</a>, as it is not available on Mac.</li>
  <li>Uses .NET core 3.1 (there have been some <a href="https://aws.amazon.com/blogs/compute/announcing-aws-lambda-supports-for-net-core-3-1/" rel="nofollow noreferrer">changes from 3.0 to 3.1 for AWS Lambda</a>)</li>
  <li>Is initiated by a HTTP request via API GW and returns a simple response</li>
  </ol>