Creating .Net6.0 AWS Lambda Function using visual studio code, building using bitbucket pipeline and deploying to AWS.

Creating .Net6.0 AWS Lambda Function using visual studio code, building using bitbucket pipeline and deploying to AWS.

We can categorise the solution into three stages

  1. Creating.Net6.0 lambda using Visual Studio Code
  2. Building the.Net6.0 lambda using bitbucket pipeline
  3. Deploying the.Net6.0 Lambda to AWS

Creating .Net6.0 Lambda Function using Visual Studio Code

Introduction

Microsoft released the first version of .NET Core (1.0), in 2016. The latest version of the. Net(6.0) was released in November 2021. Now.Net6.0 has long-term support. This version support Apple silicon(Arm64).

In this article, we are going to discuss what new features in .Net6.0.

Features

Here I am a couple of the important features of.Net6.0

  1. Hot Reload, code changes can be viewed without loading or restarting the app.
  2. Open Telemetry and dotnet monitor.
  3. FileStream is totally rewritten, now it will support asynchronous operation. It won't be blocking the thread.
  4. Arm64 Support
  5. render blazer components from javascript.
  6. HTTP/3 support, NET 6 supports the new version of HTTP, i.e., HTTP/3. A new connection protocol called QUIC solves the existing performance and operational challenges of HTTP/3. QUIC is efficient in establishing faster connections that are independent of the IP address. This feature ensures that mobile clients can easily switch between cellular and Wi-fi networks.
  7. Support for c# 10 and F# 6.
  8. Nuget package validation, check for the NuGet package contains any breaking changes.
  9. Overall performance is greatly increased.
  10. Source Build, organizations like Red Hat can build .NET projects from the source and readily offer their builds to different users

.Net 6.0 has long-term support(LTS), which supports up to 3 years. It can be deployed in Windows, Linux and macOS operating systems including Apple Silicon and windows Arm64.

AWS Lambda

AWS Lambda is a serverless computing application in Amazon Web Services (AWS).

AWS Lambda is a self-contained application which can be supported in multiple languages and operating systems.

Serverless computing has gained popularity in the last few years primarily because it supports both ease of development and high scalability. Serverless functions are stateless, event-driven, and highly scalable, and they don’t have any dependencies on the underlying infrastructure. AWS Lambda is the leading example of a serverless computing platform.

Prerequisites

Creating Lambda As an API project using visual studio code.

Step1 :

Install the visual studio code

Step2 :

Launch the visual studio code, Open terminal window

CodeTerminal.PNG

.Net 6.0 has long-term support(LTS), which supports up to 3 years. It can be deployed in Windows, Linux and macOS operating systems including Apple Silicon and windows Arm64.

AWS Lambda

AWS Lambda is a serverless computing application in Amazon Web Services (AWS).

AWS Lambda is a self-contained application which can be supported in multiple languages and operating systems.

Serverless computing has gained popularity in the last few years primarily because it supports both ease of development and high scalability. Serverless functions are stateless, event-driven, and highly scalable, and they don’t have any dependencies on the underlying infrastructure. AWS Lambda is the leading example of a serverless computing platform.

Prerequisites

Creating Lambda As an API project using visual studio code.

Step1 :

Install the visual studio code

Step2 :

Launch the visual studio code, Open terminal window

projectstructure.png

Step3:

Create solution a solution item, create a .net 6 lambda project and add the lambda project to the solution. We will be using the below commands to create a .Net solution and its items

  1. mkdir Api.Testing
  2. cd Api.Testing
  3. dotnet new sln --name "Api.Testing" (name of the solution)
  4. dotnet new serverless.AspNetCoreWebAPI  --name "Api.Testing.Lambda" 
  5. dotnet sln add -s lambda ".\Api.Testing.Lambda\src\Api.Testing.Lambda\"

One solution has been created, open in visual studio code and the folder structure will look showed in the below picture.

projectstructure.png

step4

Once the solution has been created, now we need to run the application. We need to type the below commands in the visual studio terminal.

Note: make sure to navigate to the path where the solution item resides in the terminal.

dotnet run -p 'C:\Temp\Api.Testing\Api.Testing.Lambda\src\Api.Testing.Lambda\Api.Testing.Lambda.csproj'

After running the above command, the server will be started and listen to a specific port. Here in my case port is 5000 for HTTP requests and 5001 for HTTPS requests.

running server.png

By default, the serverless project template (serverless.AspNetCoreWebAPI) has a values controller. When we include the below URL in google chrome we can see values controller data.

Chrome values data.png

In the next tutorial, we will discuss [[how we can build the application using bitbucket]].