Skip to content

Commit 2ab8107

Browse files
committed
.NET app updates for blank-csharp, blank-csharp-with-layer
1 parent d23c322 commit 2ab8107

File tree

8 files changed

+248
-247
lines changed

8 files changed

+248
-247
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.DS_Store
Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
# Blank function with layer (C#)
2-
3-
![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png)
4-
5-
The project source includes function code and supporting resources:
6-
7-
- `src/blank-csharp` - A C# .NET Core function.
8-
- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
9-
10-
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.
11-
12-
# Requirements
13-
- [.NET Core SDK 6.0](https://dotnet.microsoft.com/download/dotnet-core/6.0)
14-
- [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.
15-
- 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.
16-
- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer.
17-
18-
# Setup
19-
Download or clone this repository.
20-
21-
$ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git
22-
$ cd aws-lambda-developer-guide/sample-apps/blank-csharp
23-
24-
To create a new bucket for deployment artifacts, run `1-create-bucket-and-role.sh`.
25-
26-
blank-csharp$ ./1-create-bucket.sh
27-
make_bucket: lambda-artifacts-d7aec9f2022ef2b4
28-
make_bucket: lambda-artifacts-d7aec9f2022ef2b4-dotnet-layer
29-
{
30-
"Role": {
31-
"Path": "/",
32-
"RoleName": "blank-csharp-role",
33-
"RoleId": "AROA6HOIFXAKKWARP5RSC",
34-
"Arn": "arn:aws:iam::978061735956:role/blank-csharp-role",
35-
"CreateDate": "2023-08-22T18:12:29+00:00",
36-
"AssumeRolePolicyDocument": {
37-
"Version": "2012-10-17",
38-
"Statement": [
39-
{
40-
"Effect": "Allow",
41-
"Action": [
42-
"sts:AssumeRole"
43-
],
44-
"Principal": {
45-
"Service": [
46-
"lambda.amazonaws.com"
47-
]
48-
}
49-
}
50-
]
51-
}
52-
}
53-
}
54-
55-
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.
56-
57-
blank-csharp$ ./2-build-layer.sh
58-
59-
# Deploy
60-
To deploy the application, run `3-deploy.sh`.
61-
62-
blank-csharp$ ./3-deploy.sh
63-
Amazon Lambda Tools for .NET Core applications (5.8.0)
64-
...
65-
Created publish archive ...
66-
Creating new Lambda function blank-csharp
67-
New Lambda function created
68-
69-
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.
70-
71-
To invoke the function, run `4-invoke.sh`.
72-
73-
blank-csharp$ ./4-invoke.sh
74-
{
75-
"StatusCode": 200,
76-
"ExecutedVersion": "$LATEST"
77-
}
78-
{"FunctionCount":13,"TotalCodeSize":598094248}
79-
80-
Let the script invoke the function a few times and then press `CRTL+C` to exit.
81-
82-
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.
83-
84-
![Service Map](/sample-apps/blank-csharp-with-layer/images/blank-csharp-servicemap.png)
85-
86-
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.
87-
88-
![Trace](/sample-apps/blank-csharp-with-layer/images/blank-csharp-trace.png)
89-
90-
# Cleanup
91-
To delete the application, run the cleanup script.
92-
93-
blank-csharp$ ./5-cleanup.sh
1+
# Blank function with layer (C#)
2+
3+
![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png)
4+
5+
The project source includes function code and supporting resources:
6+
7+
- `src/blank-csharp` - A C# .NET Core function.
8+
- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
9+
10+
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.
11+
12+
# Requirements
13+
- [.NET Core SDK 8.0](https://dotnet.microsoft.com/download/dotnet-core/8.0)
14+
- [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.
15+
- 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.
16+
- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer.
17+
18+
# Setup
19+
Download or clone this repository.
20+
21+
$ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git
22+
$ cd aws-lambda-developer-guide/sample-apps/blank-csharp
23+
24+
To create a new bucket for deployment artifacts, run `1-create-bucket-and-role.sh`.
25+
26+
blank-csharp$ ./1-create-bucket.sh
27+
make_bucket: lambda-artifacts-d7aec9f2022ef2b4
28+
make_bucket: lambda-artifacts-d7aec9f2022ef2b4-dotnet-layer
29+
{
30+
"Role": {
31+
"Path": "/",
32+
"RoleName": "blank-csharp-role",
33+
"RoleId": "AROA6HOIFXAKKWARP5RSC",
34+
"Arn": "arn:aws:iam::978061735956:role/blank-csharp-role",
35+
"CreateDate": "2023-08-22T18:12:29+00:00",
36+
"AssumeRolePolicyDocument": {
37+
"Version": "2012-10-17",
38+
"Statement": [
39+
{
40+
"Effect": "Allow",
41+
"Action": [
42+
"sts:AssumeRole"
43+
],
44+
"Principal": {
45+
"Service": [
46+
"lambda.amazonaws.com"
47+
]
48+
}
49+
}
50+
]
51+
}
52+
}
53+
}
54+
55+
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.
56+
57+
blank-csharp$ ./2-build-layer.sh
58+
59+
# Deploy
60+
To deploy the application, run `3-deploy.sh`.
61+
62+
blank-csharp$ ./3-deploy.sh
63+
Amazon Lambda Tools for .NET Core applications (5.8.0)
64+
...
65+
Created publish archive ...
66+
Creating new Lambda function blank-csharp
67+
New Lambda function created
68+
69+
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.
70+
71+
To invoke the function, run `4-invoke.sh`.
72+
73+
blank-csharp$ ./4-invoke.sh
74+
{
75+
"StatusCode": 200,
76+
"ExecutedVersion": "$LATEST"
77+
}
78+
{"FunctionCount":13,"TotalCodeSize":598094248}
79+
80+
Let the script invoke the function a few times and then press `CRTL+C` to exit.
81+
82+
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.
83+
84+
![Service Map](/sample-apps/blank-csharp-with-layer/images/blank-csharp-servicemap.png)
85+
86+
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.
87+
88+
![Trace](/sample-apps/blank-csharp-with-layer/images/blank-csharp-trace.png)
89+
90+
# Cleanup
91+
To delete the application, run the cleanup script.
92+
93+
blank-csharp$ ./5-cleanup.sh
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
{
2-
"Information" : [
3-
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4-
"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.",
5-
6-
"dotnet lambda help",
7-
8-
"All the command line options for the Lambda command can be specified in this file."
9-
],
10-
11-
"profile":"default",
12-
"region" : "us-east-1",
13-
"configuration" : "Release",
14-
"framework" : "net6.0",
15-
"function-runtime":"dotnet6",
16-
"function-memory-size" : 512,
17-
"function-timeout" : 30,
18-
"function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler",
19-
"function-role" : "blank-csharp-role"
20-
}
1+
{
2+
"Information" : [
3+
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4+
"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.",
5+
6+
"dotnet lambda help",
7+
8+
"All the command line options for the Lambda command can be specified in this file."
9+
],
10+
11+
"profile":"default",
12+
"region" : "us-east-1",
13+
"configuration" : "Release",
14+
"framework" : "net8.0",
15+
"function-runtime":"dotnet8",
16+
"function-memory-size" : 512,
17+
"function-timeout" : 30,
18+
"function-handler" : "blank-csharp::blankCsharp.Function::FunctionHandler",
19+
"function-role" : "blank-csharp-role"
20+
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
4-
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
5-
<AWSProjectType>Lambda</AWSProjectType>
6-
</PropertyGroup>
7-
<ItemGroup>
8-
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
9-
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="2.1.0" />
10-
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.1.0" />
11-
<PackageReference Include="AWSSDK.Core" Version="3.7.103.24" />
12-
<PackageReference Include="AWSSDK.Lambda" Version="3.7.104.3" />
13-
<PackageReference Include="AWSXRayRecorder.Core" Version="2.13.0" />
14-
<PackageReference Include="AWSXRayRecorder.Handlers.AwsSdk" Version="2.11.0" />
15-
</ItemGroup>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
5+
<AWSProjectType>Lambda</AWSProjectType>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
9+
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="2.1.0" />
10+
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="2.1.0" />
11+
<PackageReference Include="AWSSDK.Core" Version="3.7.103.24" />
12+
<PackageReference Include="AWSSDK.Lambda" Version="3.7.104.3" />
13+
<PackageReference Include="AWSXRayRecorder.Core" Version="2.13.0" />
14+
<PackageReference Include="AWSXRayRecorder.Handlers.AwsSdk" Version="2.11.0" />
15+
</ItemGroup>
1616
</Project>

sample-apps/blank-csharp/README.md

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
# Blank function (C#)
2-
3-
![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png)
4-
5-
The project source includes function code and supporting resources:
6-
7-
- `src/blank-csharp` - A C# .NET Core function.
8-
- `template.yml` - An AWS CloudFormation template that creates an application.
9-
- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
10-
11-
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.
12-
13-
# Requirements
14-
- [.NET Core SDK 6.0](https://dotnet.microsoft.com/download/dotnet-core/6.0)
15-
- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli)
16-
- 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.
17-
- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer.
18-
19-
# Setup
20-
Download or clone this repository.
21-
22-
$ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git
23-
$ cd aws-lambda-developer-guide/sample-apps/blank-csharp
24-
25-
To create a new bucket for deployment artifacts, run `1-create-bucket.sh`.
26-
27-
blank-csharp$ ./1-create-bucket.sh
28-
make_bucket: lambda-artifacts-a5e491dbb5b22e0d
29-
30-
# Deploy
31-
To deploy the application, run `2-deploy.sh`.
32-
33-
blank-csharp$ ./2-deploy.sh
34-
Amazon Lambda Tools for .NET Core applications (4.0.0)
35-
Executing publish command
36-
Uploading to e678bc216e6a0d510d661ca9ae2fd941 1009985 / 1009985.0 (100.00%)
37-
Successfully packaged artifacts and wrote output template to file out.yml.
38-
Waiting for changeset to be created..
39-
Waiting for stack create/update to complete
40-
Successfully created/updated stack - blank-csharp
41-
42-
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.
43-
44-
To invoke the function, run `3-invoke.sh`.
45-
46-
blank-csharp$ ./3-invoke.sh
47-
{
48-
"StatusCode": 200,
49-
"ExecutedVersion": "$LATEST"
50-
}
51-
{"FunctionCount":43,"TotalCodeSize":362867335}
52-
53-
Let the script invoke the function a few times and then press `CRTL+C` to exit.
54-
55-
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.
56-
57-
![Service Map](/sample-apps/blank-csharp/images/blank-csharp-servicemap.png)
58-
59-
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.
60-
61-
![Trace](/sample-apps/blank-csharp/images/blank-csharp-trace.png)
62-
63-
# Cleanup
64-
To delete the application, run the cleanup script.
65-
66-
blank-csharp$ ./4-cleanup.sh
1+
# Blank function (C#)
2+
3+
![Architecture](/sample-apps/blank-csharp/images/sample-blank-csharp.png)
4+
5+
The project source includes function code and supporting resources:
6+
7+
- `src/blank-csharp` - A C# .NET Core function.
8+
- `template.yml` - An AWS CloudFormation template that creates an application.
9+
- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
10+
11+
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.
12+
13+
# Requirements
14+
- [.NET Core SDK 8.0](https://dotnet.microsoft.com/download/dotnet-core/8.0)
15+
- [AWS extensions for .NET CLI](https://github.com/aws/aws-extensions-for-dotnet-cli)
16+
- 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.
17+
- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer.
18+
19+
# Setup
20+
Download or clone this repository.
21+
22+
$ git clone https://github.com/awsdocs/aws-lambda-developer-guide.git
23+
$ cd aws-lambda-developer-guide/sample-apps/blank-csharp
24+
25+
To create a new bucket for deployment artifacts, run `1-create-bucket.sh`.
26+
27+
blank-csharp$ ./1-create-bucket.sh
28+
make_bucket: lambda-artifacts-a5e491dbb5b22e0d
29+
30+
# Deploy
31+
To deploy the application, run `2-deploy.sh`.
32+
33+
blank-csharp$ ./2-deploy.sh
34+
Amazon Lambda Tools for .NET Core applications (4.0.0)
35+
Executing publish command
36+
Uploading to e678bc216e6a0d510d661ca9ae2fd941 1009985 / 1009985.0 (100.00%)
37+
Successfully packaged artifacts and wrote output template to file out.yml.
38+
Waiting for changeset to be created..
39+
Waiting for stack create/update to complete
40+
Successfully created/updated stack - blank-csharp
41+
42+
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.
43+
44+
To invoke the function, run `3-invoke.sh`.
45+
46+
blank-csharp$ ./3-invoke.sh
47+
{
48+
"StatusCode": 200,
49+
"ExecutedVersion": "$LATEST"
50+
}
51+
{"FunctionCount":43,"TotalCodeSize":362867335}
52+
53+
Let the script invoke the function a few times and then press `CRTL+C` to exit.
54+
55+
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.
56+
57+
![Service Map](/sample-apps/blank-csharp/images/blank-csharp-servicemap.png)
58+
59+
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.
60+
61+
![Trace](/sample-apps/blank-csharp/images/blank-csharp-trace.png)
62+
63+
# Cleanup
64+
To delete the application, run the cleanup script.
65+
66+
blank-csharp$ ./4-cleanup.sh

0 commit comments

Comments
 (0)