diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5509140f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.DS_Store diff --git a/sample-apps/blank-csharp-with-layer/README.md b/sample-apps/blank-csharp-with-layer/README.md index eac563d9..638db2da 100644 --- a/sample-apps/blank-csharp-with-layer/README.md +++ b/sample-apps/blank-csharp-with-layer/README.md @@ -1,93 +1,93 @@ -# Blank function with layer (C#) - -![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png) - -The project source includes function code and supporting resources: - -- `src/blank-csharp` - A C# .NET Core function. -- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application. - -Use the following instructions to deploy the sample application. For more information on the application's architecture and implementation, see [Managing Spot Instance Requests](https://docs.aws.amazon.com/lambda/latest/dg/services-ec2-tutorial.html) in the developer guide. - -# Requirements -- [.NET Core SDK 6.0](https://dotnet.microsoft.com/download/dotnet-core/6.0) -- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli). Specifically, ensure that you have [Amazon.Lambda.Tools](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) installed. -- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash. -- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer. - -# Setup -Download or clone this repository. - - $ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git - $ cd aws-lambda-developer-guide/sample-apps/blank-csharp - -To create a new bucket for deployment artifacts, run `1-create-bucket-and-role.sh`. - - blank-csharp$ ./1-create-bucket.sh - make_bucket: lambda-artifacts-d7aec9f2022ef2b4 - make_bucket: lambda-artifacts-d7aec9f2022ef2b4-dotnet-layer - { - "Role": { - "Path": "/", - "RoleName": "blank-csharp-role", - "RoleId": "AROA6HOIFXAKKWARP5RSC", - "Arn": "arn:aws:iam::978061735956:role/blank-csharp-role", - "CreateDate": "2023-08-22T18:12:29+00:00", - "AssumeRolePolicyDocument": { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Action": [ - "sts:AssumeRole" - ], - "Principal": { - "Service": [ - "lambda.amazonaws.com" - ] - } - } - ] - } - } - } - -To build a Lambda layer that contains the function's runtime dependencies, run `2-build-layer.sh`. This also uploads the layer to an S3 bucket created by the first script. - - blank-csharp$ ./2-build-layer.sh - -# Deploy -To deploy the application, run `3-deploy.sh`. - - blank-csharp$ ./3-deploy.sh - Amazon Lambda Tools for .NET Core applications (5.8.0) - ... - Created publish archive ... - Creating new Lambda function blank-csharp - New Lambda function created - -This script uses the .NET Amazon Lambda Tools to deploy the Lambda function. It uses the default settings from the `src/aws-lambda-tools-defaults.json` file. - -To invoke the function, run `4-invoke.sh`. - - blank-csharp$ ./4-invoke.sh - { - "StatusCode": 200, - "ExecutedVersion": "$LATEST" - } - {"FunctionCount":13,"TotalCodeSize":598094248} - -Let the script invoke the function a few times and then press `CRTL+C` to exit. - -The application uses AWS X-Ray to trace requests. Open the [X-Ray console](https://console.aws.amazon.com/xray/home#/service-map) to view the service map. The following service map shows the function managing spot instances in Amazon EC2. - -![Service Map](/sample-apps/blank-csharp-with-layer/images/blank-csharp-servicemap.png) - -Choose a node in the main function graph. Then choose **View traces** to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function. - -![Trace](/sample-apps/blank-csharp-with-layer/images/blank-csharp-trace.png) - -# Cleanup -To delete the application, run the cleanup script. - - blank-csharp$ ./5-cleanup.sh +# Blank function with layer (C#) + +![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png) + +The project source includes function code and supporting resources: + +- `src/blank-csharp` - A C# .NET Core function. +- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application. + +Use the following instructions to deploy the sample application. For more information on the application's architecture and implementation, see [Managing Spot Instance Requests](https://docs.aws.amazon.com/lambda/latest/dg/services-ec2-tutorial.html) in the developer guide. + +# Requirements +- [.NET Core SDK 8.0](https://dotnet.microsoft.com/download/dotnet-core/8.0) +- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli). Specifically, ensure that you have [Amazon.Lambda.Tools](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) installed. +- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash. +- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer. + +# Setup +Download or clone this repository. + + $ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git + $ cd aws-lambda-developer-guide/sample-apps/blank-csharp + +To create a new bucket for deployment artifacts, run `1-create-bucket-and-role.sh`. + + blank-csharp$ ./1-create-bucket.sh + make_bucket: lambda-artifacts-d7aec9f2022ef2b4 + make_bucket: lambda-artifacts-d7aec9f2022ef2b4-dotnet-layer + { + "Role": { + "Path": "/", + "RoleName": "blank-csharp-role", + "RoleId": "AROA6HOIFXAKKWARP5RSC", + "Arn": "arn:aws:iam::978061735956:role/blank-csharp-role", + "CreateDate": "2023-08-22T18:12:29+00:00", + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "sts:AssumeRole" + ], + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + } + } + ] + } + } + } + +To build a Lambda layer that contains the function's runtime dependencies, run `2-build-layer.sh`. This also uploads the layer to an S3 bucket created by the first script. + + blank-csharp$ ./2-build-layer.sh + +# Deploy +To deploy the application, run `3-deploy.sh`. + + blank-csharp$ ./3-deploy.sh + Amazon Lambda Tools for .NET Core applications (5.8.0) + ... + Created publish archive ... + Creating new Lambda function blank-csharp + New Lambda function created + +This script uses the .NET Amazon Lambda Tools to deploy the Lambda function. It uses the default settings from the `src/aws-lambda-tools-defaults.json` file. + +To invoke the function, run `4-invoke.sh`. + + blank-csharp$ ./4-invoke.sh + { + "StatusCode": 200, + "ExecutedVersion": "$LATEST" + } + {"FunctionCount":13,"TotalCodeSize":598094248} + +Let the script invoke the function a few times and then press `CRTL+C` to exit. + +The application uses AWS X-Ray to trace requests. Open the [X-Ray console](https://console.aws.amazon.com/xray/home#/service-map) to view the service map. The following service map shows the function managing spot instances in Amazon EC2. + +![Service Map](/sample-apps/blank-csharp-with-layer/images/blank-csharp-servicemap.png) + +Choose a node in the main function graph. Then choose **View traces** to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function. + +![Trace](/sample-apps/blank-csharp-with-layer/images/blank-csharp-trace.png) + +# Cleanup +To delete the application, run the cleanup script. + + blank-csharp$ ./5-cleanup.sh \ No newline at end of file diff --git a/sample-apps/blank-csharp-with-layer/src/blank-csharp/aws-lambda-tools-defaults.json b/sample-apps/blank-csharp-with-layer/src/blank-csharp/aws-lambda-tools-defaults.json index 9a237927..1149f222 100644 --- a/sample-apps/blank-csharp-with-layer/src/blank-csharp/aws-lambda-tools-defaults.json +++ b/sample-apps/blank-csharp-with-layer/src/blank-csharp/aws-lambda-tools-defaults.json @@ -1,20 +1,20 @@ -{ - "Information" : [ - "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", - "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", - - "dotnet lambda help", - - "All the command line options for the Lambda command can be specified in this file." - ], - - "profile":"default", - "region" : "us-east-1", - "configuration" : "Release", - "framework" : "net6.0", - "function-runtime":"dotnet6", - "function-memory-size" : 512, - "function-timeout" : 30, - "function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler", - "function-role" : "blank-csharp-role" -} +{ + "Information" : [ + "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", + "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", + + "dotnet lambda help", + + "All the command line options for the Lambda command can be specified in this file." + ], + + "profile":"default", + "region" : "us-east-1", + "configuration" : "Release", + "framework" : "net8.0", + "function-runtime":"dotnet8", + "function-memory-size" : 512, + "function-timeout" : 30, + "function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler", + "function-role" : "blank-csharp-role" +} diff --git a/sample-apps/blank-csharp-with-layer/src/blank-csharp/blank-csharp.csproj b/sample-apps/blank-csharp-with-layer/src/blank-csharp/blank-csharp.csproj index aa648b33..4e36256f 100644 --- a/sample-apps/blank-csharp-with-layer/src/blank-csharp/blank-csharp.csproj +++ b/sample-apps/blank-csharp-with-layer/src/blank-csharp/blank-csharp.csproj @@ -1,16 +1,16 @@ - - - net6.0 - true - Lambda - - - - - - - - - - + + + net8.0 + true + Lambda + + + + + + + + + + \ No newline at end of file diff --git a/sample-apps/blank-csharp/README.md b/sample-apps/blank-csharp/README.md index ad905416..a731ea2c 100644 --- a/sample-apps/blank-csharp/README.md +++ b/sample-apps/blank-csharp/README.md @@ -1,66 +1,66 @@ -# Blank function (C#) - -![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png) - -The project source includes function code and supporting resources: - -- `src/blank-csharp` - A C# .NET Core function. -- `template.yml` - An AWS CloudFormation template that creates an application. -- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application. - -Use the following instructions to deploy the sample application. For more information on the application's architecture and implementation, see [Managing Spot Instance Requests](https://docs.aws.amazon.com/lambda/latest/dg/services-ec2-tutorial.html) in the developer guide. - -# Requirements -- [.NET Core SDK 6.0](https://dotnet.microsoft.com/download/dotnet-core/6.0) -- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli) -- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash. -- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer. - -# Setup -Download or clone this repository. - - $ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git - $ cd aws-lambda-developer-guide/sample-apps/blank-csharp - -To create a new bucket for deployment artifacts, run `1-create-bucket.sh`. - - blank-csharp$ ./1-create-bucket.sh - make_bucket: lambda-artifacts-a5e491dbb5b22e0d - -# Deploy -To deploy the application, run `2-deploy.sh`. - - blank-csharp$ ./2-deploy.sh - Amazon Lambda Tools for .NET Core applications (4.0.0) - Executing publish command - Uploading to e678bc216e6a0d510d661ca9ae2fd941 1009985 / 1009985.0 (100.00%) - Successfully packaged artifacts and wrote output template to file out.yml. - Waiting for changeset to be created.. - Waiting for stack create/update to complete - Successfully created/updated stack - blank-csharp - -This script uses AWS CloudFormation to deploy the Lambda functions and an IAM role. If the AWS CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code. - -To invoke the function, run `3-invoke.sh`. - - blank-csharp$ ./3-invoke.sh - { - "StatusCode": 200, - "ExecutedVersion": "$LATEST" - } - {"FunctionCount":43,"TotalCodeSize":362867335} - -Let the script invoke the function a few times and then press `CRTL+C` to exit. - -The application uses AWS X-Ray to trace requests. Open the [X-Ray console](https://console.aws.amazon.com/xray/home#/service-map) to view the service map. The following service map shows the function managing spot instances in Amazon EC2. - -![Service Map](/sample-apps/blank-csharp/images/blank-csharp-servicemap.png) - -Choose a node in the main function graph. Then choose **View traces** to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function. - -![Trace](/sample-apps/blank-csharp/images/blank-csharp-trace.png) - -# Cleanup -To delete the application, run the cleanup script. - - blank-csharp$ ./4-cleanup.sh +# Blank function (C#) + +![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png) + +The project source includes function code and supporting resources: + +- `src/blank-csharp` - A C# .NET Core function. +- `template.yml` - An AWS CloudFormation template that creates an application. +- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application. + +Use the following instructions to deploy the sample application. For more information on the application's architecture and implementation, see [Managing Spot Instance Requests](https://docs.aws.amazon.com/lambda/latest/dg/services-ec2-tutorial.html) in the developer guide. + +# Requirements +- [.NET Core SDK 8.0](https://dotnet.microsoft.com/download/dotnet-core/8.0) +- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli) +- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash. +- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer. + +# Setup +Download or clone this repository. + + $ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git + $ cd aws-lambda-developer-guide/sample-apps/blank-csharp + +To create a new bucket for deployment artifacts, run `1-create-bucket.sh`. + + blank-csharp$ ./1-create-bucket.sh + make_bucket: lambda-artifacts-a5e491dbb5b22e0d + +# Deploy +To deploy the application, run `2-deploy.sh`. + + blank-csharp$ ./2-deploy.sh + Amazon Lambda Tools for .NET Core applications (4.0.0) + Executing publish command + Uploading to e678bc216e6a0d510d661ca9ae2fd941 1009985 / 1009985.0 (100.00%) + Successfully packaged artifacts and wrote output template to file out.yml. + Waiting for changeset to be created.. + Waiting for stack create/update to complete + Successfully created/updated stack - blank-csharp + +This script uses AWS CloudFormation to deploy the Lambda functions and an IAM role. If the AWS CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code. + +To invoke the function, run `3-invoke.sh`. + + blank-csharp$ ./3-invoke.sh + { + "StatusCode": 200, + "ExecutedVersion": "$LATEST" + } + {"FunctionCount":43,"TotalCodeSize":362867335} + +Let the script invoke the function a few times and then press `CRTL+C` to exit. + +The application uses AWS X-Ray to trace requests. Open the [X-Ray console](https://console.aws.amazon.com/xray/home#/service-map) to view the service map. The following service map shows the function managing spot instances in Amazon EC2. + +![Service Map](/sample-apps/blank-csharp/images/blank-csharp-servicemap.png) + +Choose a node in the main function graph. Then choose **View traces** to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function. + +![Trace](/sample-apps/blank-csharp/images/blank-csharp-trace.png) + +# Cleanup +To delete the application, run the cleanup script. + + blank-csharp$ ./4-cleanup.sh \ No newline at end of file diff --git a/sample-apps/blank-csharp/src/blank-csharp/aws-lambda-tools-defaults.json b/sample-apps/blank-csharp/src/blank-csharp/aws-lambda-tools-defaults.json index c815dcf9..8a9c7869 100644 --- a/sample-apps/blank-csharp/src/blank-csharp/aws-lambda-tools-defaults.json +++ b/sample-apps/blank-csharp/src/blank-csharp/aws-lambda-tools-defaults.json @@ -1,19 +1,19 @@ -{ - "Information" : [ - "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", - "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", - - "dotnet lambda help", - - "All the command line options for the Lambda command can be specified in this file." - ], - - "profile":"default", - "region" : "us-east-2", - "configuration" : "Release", - "framework" : "net6.0", - "function-runtime":"dotnet6", - "function-memory-size" : 512, - "function-timeout" : 30, - "function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler" -} +{ + "Information" : [ + "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", + "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", + + "dotnet lambda help", + + "All the command line options for the Lambda command can be specified in this file." + ], + + "profile":"default", + "region" : "us-east-2", + "configuration" : "Release", + "framework" : "net8.0", + "function-runtime":"dotnet8", + "function-memory-size" : 512, + "function-timeout" : 30, + "function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler" +} \ No newline at end of file diff --git a/sample-apps/blank-csharp/src/blank-csharp/blank-csharp.csproj b/sample-apps/blank-csharp/src/blank-csharp/blank-csharp.csproj index aa648b33..4e36256f 100644 --- a/sample-apps/blank-csharp/src/blank-csharp/blank-csharp.csproj +++ b/sample-apps/blank-csharp/src/blank-csharp/blank-csharp.csproj @@ -1,16 +1,16 @@ - - - net6.0 - true - Lambda - - - - - - - - - - + + + net8.0 + true + Lambda + + + + + + + + + + \ No newline at end of file diff --git a/sample-apps/blank-csharp/template.yml b/sample-apps/blank-csharp/template.yaml similarity index 80% rename from sample-apps/blank-csharp/template.yml rename to sample-apps/blank-csharp/template.yaml index 17836497..c92e6a35 100644 --- a/sample-apps/blank-csharp/template.yml +++ b/sample-apps/blank-csharp/template.yaml @@ -1,19 +1,19 @@ -AWSTemplateFormatVersion: '2010-09-09' -Transform: 'AWS::Serverless-2016-10-31' -Description: An AWS Lambda application that calls the Lambda API. -Resources: - function: - Type: AWS::Serverless::Function - Properties: - Handler: blank-csharp::blankCsharp.Function::FunctionHandler - Runtime: dotnetcore3.1 - CodeUri: src/blank-csharp/bin/Release/netcoreapp3.1/blank-csharp.zip - Description: Call the AWS Lambda API - MemorySize: 256 - Timeout: 9 - # Function's execution role - Policies: - - AWSLambdaBasicExecutionRole - - AWSLambda_ReadOnlyAccess - - AWSXrayWriteOnlyAccess - Tracing: Active +AWSTemplateFormatVersion: '2010-09-09' +Transform: 'AWS::Serverless-2016-10-31' +Description: An AWS Lambda application that calls the Lambda API. +Resources: + function: + Type: AWS::Serverless::Function + Properties: + Handler: blank-csharp::blankCsharp.Function::FunctionHandler + Runtime: dotnet8 + CodeUri: src/blank-csharp/bin/Release/net8.0/blank-csharp.zip + Description: Call the AWS Lambda API + MemorySize: 256 + Timeout: 9 + # Function's execution role + Policies: + - AWSLambdaBasicExecutionRole + - AWSLambda_ReadOnlyAccess + - AWSXrayWriteOnlyAccess + Tracing: Active \ No newline at end of file