Today we released support for the new .NET Core 2.1.0 runtime in AWS Lambda. You can now take advantage of this version’s more performant HTTP client. This is particularly important when integrating with other AWS services from your AWS Lambda function. You can also start using highly anticipated new language features such as Span<T> and Memory<T>.

We encourage you to update your .NET Core 2.0 AWS Lambda functions to use .NET Core 2.1 as soon as possible. Microsoft is expected to provide long-term support (LTS) for .NET Core 2.1 starting later this summer, and will continue that support for three years. Microsoft will end its support for .NET Core 2.0 at the beginning of October, 2018[2]. At that time, .NET Core 2.0 AWS Lambda functions will be subject to deprecation per the AWS Lambda Runtime Support Policy. After three months, you will no longer be able to create AWS Lambda functions using .NET Core 2.0, although you will be able to update existing functions. After six months, update functionality will also be disabled.

[1] See Microsoft Support for .NET Core for the latest details on Microsoft’s .NET Core support.

[2] See this blog post from Microsoft about .NET Core 2.0’s end of life.

Important changes

Tooling updates

You’ll need to use the latest versions of our tools to start working with .NET Core 2.1 in AWS Lambda. Download version 1.14.4.0 of the AWS Toolkit for Visual Studio or reference version 2.2.0 of the Amazon.Lambda.Tools nuget package from your project file to build, package, and deploy .NET Core 2.1 AWS Lambda functions..

Microsoft.AspNetCore.All and Microsoft.AspNetCore.App

If your AWS Lambda function is using ASP.NET Core then your reference to Microsoft.AspNetCore.All or Microsoft.AspNetCore.App in your project file must specify a version in the <PackageReference> element. Currently, 2.1.0 is the only version supported by the .NET Core 2.1 AWS Lambda runtime. Your <PackageReference> can be updated as we upgrade the .NET Core AWS Lambda runtime with the latest patch versions.[3]

If you omit the version from the reference, your deployment package will be tied to the specific version installed on your machine. That version may not be supported by AWS Lambda. The newest versions of the AWS Toolkit for Visual Studio and the dotnet lambda CLI will check that the version you’ve referenced is supported, before deploying to AWS Lambda.

Preparation for Global Tools

We’re in the process of updating the dotnet lambda CLI to support the new Global Tools feature of the .NET Core SDK[4]. In preparation, we’ve changed how the AWS Toolkit for Visual Studio detects an AWS Lambda project. You might notice a new property, <AWSProjectType>Lambda</AWSProjectType> , in the csproj file for your AWS Lambda function. When you publish your project to an AWS Lambda function, the new property is added to your csproj file to indicate that it’s an AWS Lambda project.

Previously, the AWS Toolkit for Visual Studio provided context menu options related to AWS Lambda if your project contained a <DotNetCliToolReference> reference to the Amazon.Lambda.Tools package. With Global Tools support, your project won’t necessarily reference Amazon.Lambda.Tools so the new property is necessary. Both methods will be used to detect AWS Lambda projects so the transition to Global Tools will work seamlessly.

[3] We’re working on the .NET Core 2.1.2 update and will make it available in the AWS Lambda environment as soon as we can.

[4] See the .NET Core Global Tools overview for an explanation of Global Tools.

Migrating a .NET Core 2.0 AWS Lambda function to .NET Core 2.1

The following example shows an updated csproj file:

<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <!--Changed from netcoreapp2.0.--> <TargetFramework>netcoreapp2.1</TargetFramework> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <!--Added by AWS Toolkit for Visual Studio on publish to AWS Lambda.--> <!--Tells the AWS Toolkit for Visual Studio that this is an AWS Lambda Project.--> <AWSProjectType>Lambda</AWSProjectType> </PropertyGroup> <ItemGroup> <!--Change to version 2.2.0 of Amazon.Lambda.Tools to get .NET Core 2.1 support for Lambda AWS--> <!--This will be gone once the dotnet lambda CLI supports Global Tools.--> <!--Tells the AWS Toolkit for Visual Studio that this is an AWS Lambda Project.--> <DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="2.2.0" /> </ItemGroup> <ItemGroup> <!--Change to use Microsoft.AspNetCore.App and reference version 2.1.0--> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0"/> <PackageReference Include="Amazon.Lambda.Core" Version="1.0.0" /> <PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="1.1.3" /> <PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="2.0.4" /> <PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.2.0" /> </ItemGroup> </Project>

The following example shows an updated aws-lambda-tools-defaults.json file:

// framework has been changed from netcoreapp2.0 to netcoreapp2.1 // function-runtime has been changed from dotnetcore2.0 to dotnetcore2.1 { "Information": [ "" ], "region": "us-west-2", "configuration": "Debug", "framework": "netcoreapp2.1", "function-runtime": "dotnetcore2.1", "function-memory-size": 128, "function-timeout": 30, "function-handler": "DotNetCoreSampleFunction::DotNetCoreSampleFunction.TestDotNetCore::HelloWorld", "function-name": "HelloWorld", "tracing-mode": "PassThrough" }

Final notes

You can find the latest versions of all of our .NET Core AWS Lambda tools and libraries in our aws-lambda-dotnet GitHub repo.

As mentioned in [3], we’re working on the .NET Core 2.1.2 update that came out in July. We’ll make it available in the AWS Lambda environment as soon as we can.