We are excited to announce the launch of support for the .NET Core 2.1.0 runtime in AWS Lambda. This upgrade allows developers to utilize a more efficient HTTP client, which is particularly beneficial when connecting with other AWS services from your Lambda functions. Additionally, you can start leveraging sought-after new language features such as Span<T>
and Memory<T>
.
We highly recommend updating your existing .NET Core 2.0 AWS Lambda functions to .NET Core 2.1 at your earliest convenience. Microsoft is set to provide long-term support (LTS) for .NET Core 2.1 starting later this summer, maintaining it for three years. Support for .NET Core 2.0 will officially end in early October 2018. After this date, AWS Lambda functions running on .NET Core 2.0 will be marked for deprecation in accordance with our Runtime Support Policy. After a three-month grace period, creating new functions with .NET Core 2.0 will no longer be possible, although existing functions can still be updated. However, after six months, even update capabilities will be disabled.
For more information, you can refer to this blog post for further details. It’s essential to stay informed as Microsoft’s end of life announcement for .NET Core 2.0 can be found here, as they are an authority on the topic.
Key Changes to Note
Tooling Updates
To work with .NET Core 2.1 in AWS Lambda, ensure you are using the latest versions of our tools. You can 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 in your project file to build, package, and deploy your .NET Core 2.1 AWS Lambda functions.
Microsoft.AspNetCore.All and Microsoft.AspNetCore.App
If your AWS Lambda function utilizes ASP.NET Core, it is crucial to specify a version in the <PackageReference>
element for Microsoft.AspNetCore.All or Microsoft.AspNetCore.App in your project file. Currently, only version 2.1.0 is supported by the .NET Core 2.1 AWS Lambda runtime. Your <PackageReference>
may need to be updated as we roll out new patch versions.
If you forget to include the version in your reference, your deployment package will be linked to the specific version installed on your local machine, which may not be supported by AWS Lambda. The latest versions of the AWS Toolkit for Visual Studio and the dotnet lambda CLI will verify that the referenced version is supported prior to deployment.
Preparation for Global Tools
We are currently updating the dotnet lambda CLI to accommodate the new Global Tools feature of the .NET Core SDK. As part of this process, the AWS Toolkit for Visual Studio will now detect AWS Lambda projects differently. You may notice a new property, <AWSProjectType>Lambda</AWSProjectType>
, in the csproj file of your AWS Lambda function, indicating its project type.
Previously, context menu options related to AWS Lambda were provided if your project contained a <DotNetCliToolReference>
to the Amazon.Lambda.Tools package. With the introduction of Global Tools support, your project might not necessarily reference Amazon.Lambda.Tools, making the new property essential. Both detection methods will be utilized to ensure a smooth transition to Global Tools.
Migrating from .NET Core 2.0 to 2.1
Here is an example of an updated csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="Amazon.Lambda.Tools" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<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>
And here is an updated aws-lambda-tools-defaults.json file:
{
"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 most recent versions of our .NET Core AWS Lambda tools and libraries in our aws-lambda-dotnet GitHub repository. We look forward to releasing the .NET Core 2.1.2 update, which was announced in July, in the AWS Lambda environment as soon as possible.
Leave a Reply