Skip to content

Commit 18283d5

Browse files
committed
💁
1 parent ebb105c commit 18283d5

40 files changed

+162
-261
lines changed

samples/CommandQuery.Sample.AWSLambda.Tests/CommandQuery.Sample.AWSLambda.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsTestProject>true</IsTestProject>
66
</PropertyGroup>
77

@@ -20,4 +20,4 @@
2020
<ProjectReference Include="..\CommandQuery.Sample.AWSLambda\CommandQuery.Sample.AWSLambda.csproj" />
2121
</ItemGroup>
2222

23-
</Project>
23+
</Project>

samples/CommandQuery.Sample.AWSLambda.Tests/CommandTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Threading.Tasks;
21
using Amazon.Lambda.APIGatewayEvents;
32
using Amazon.Lambda.TestUtilities;
43
using CommandQuery.AWSLambda;

samples/CommandQuery.Sample.AWSLambda.Tests/QueryTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections.Generic;
2-
using System.Threading.Tasks;
31
using Amazon.Lambda.APIGatewayEvents;
42
using Amazon.Lambda.Core;
53
using Amazon.Lambda.TestUtilities;
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
4+
<TargetFramework>net8.0</TargetFramework>
75
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
86
<AWSProjectType>Lambda</AWSProjectType>
97
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
@@ -13,17 +11,17 @@
1311
</PropertyGroup>
1412

1513
<ItemGroup>
16-
<PackageReference Include="Amazon.Lambda.Annotations" Version="1.1.0" />
14+
<PackageReference Include="Amazon.Lambda.Annotations" Version="1.5.0" />
1715
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
18-
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
16+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
1917
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
2018
<PackageReference Include="CommandQuery.AWSLambda" Version="3.0.0" />
21-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
19+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
2220
</ItemGroup>
2321

2422
<ItemGroup>
2523
<ProjectReference Include="..\CommandQuery.Sample.Contracts\CommandQuery.Sample.Contracts.csproj" />
2624
<ProjectReference Include="..\CommandQuery.Sample.Handlers\CommandQuery.Sample.Handlers.csproj" />
2725
</ItemGroup>
2826

29-
</Project>
27+
</Project>

samples/CommandQuery.Sample.AWSLambda/Properties/launchSettings.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"profiles": {
44
"Mock Lambda Test Tool": {
55
"commandName": "Executable",
6-
"commandLineArgs": "--port 5050",
7-
"workingDirectory": ".\\bin\\$(Configuration)\\net6.0",
8-
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-6.0.exe"
6+
"commandLineArgs": "--port 7071",
7+
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
8+
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe"
99
}
1010
}
11-
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
21
{
3-
"Information" : [
4-
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
5-
"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.",
6-
"dotnet lambda help",
7-
"All the command line options for the Lambda command can be specified in this file."
8-
],
9-
"profile" : "Henrik Lau Eriksson",
10-
"region" : "eu-central-1",
11-
"configuration" : "Release",
12-
"framework" : "net6.0",
13-
"s3-prefix" : "CommandQuery.Sample.AWSLambda/",
14-
"template" : "serverless.template",
15-
"template-parameters" : "",
16-
"s3-bucket" : "commandquery",
17-
"stack-name" : "CommandQuery"
18-
}
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+
"dotnet lambda help",
6+
"All the command line options for the Lambda command can be specified in this file."
7+
],
8+
"profile": "Henrik Lau Eriksson",
9+
"region": "eu-central-1",
10+
"configuration": "Release",
11+
"framework": "net8.0",
12+
"s3-prefix": "CommandQuery.Sample.AWSLambda/",
13+
"template": "serverless.template",
14+
"template-parameters": "",
15+
"s3-bucket": "commandquery",
16+
"stack-name": "CommandQuery"
17+
}

samples/CommandQuery.Sample.AWSLambda/serverless.template

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
{
22
"AWSTemplateFormatVersion": "2010-09-09",
33
"Transform": "AWS::Serverless-2016-10-31",
4-
"Description": "An AWS Serverless Application. This template is partially managed by Amazon.Lambda.Annotations (v1.0.0.0).",
4+
"Description": "An AWS Serverless Application. This template is partially managed by Amazon.Lambda.Annotations (v1.5.0.0).",
55
"Resources": {
66
"CommandQuerySampleAWSLambdaCommandHandleGenerated": {
77
"Type": "AWS::Serverless::Function",
88
"Metadata": {
99
"Tool": "Amazon.Lambda.Annotations",
1010
"SyncedEvents": [
1111
"RootPost"
12-
]
12+
],
13+
"SyncedEventProperties": {
14+
"RootPost": [
15+
"Path",
16+
"Method"
17+
]
18+
}
1319
},
1420
"Properties": {
15-
"Runtime": "dotnet6",
21+
"Architectures": [
22+
"x86_64"
23+
],
24+
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Command_Handle_Generated::Handle",
25+
"Runtime": "dotnet8",
1626
"CodeUri": ".",
1727
"MemorySize": 256,
1828
"Timeout": 30,
1929
"Policies": [
2030
"AWSLambdaBasicExecutionRole"
2131
],
2232
"PackageType": "Zip",
23-
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Command_Handle_Generated::Handle",
2433
"Events": {
2534
"RootPost": {
2635
"Type": "Api",
@@ -38,18 +47,27 @@
3847
"Tool": "Amazon.Lambda.Annotations",
3948
"SyncedEvents": [
4049
"RootGet"
41-
]
50+
],
51+
"SyncedEventProperties": {
52+
"RootGet": [
53+
"Path",
54+
"Method"
55+
]
56+
}
4257
},
4358
"Properties": {
44-
"Runtime": "dotnet6",
59+
"Architectures": [
60+
"x86_64"
61+
],
62+
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Query_Get_Generated::Get",
63+
"Runtime": "dotnet8",
4564
"CodeUri": ".",
4665
"MemorySize": 256,
4766
"Timeout": 30,
4867
"Policies": [
4968
"AWSLambdaBasicExecutionRole"
5069
],
5170
"PackageType": "Zip",
52-
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Query_Get_Generated::Get",
5371
"Events": {
5472
"RootGet": {
5573
"Type": "Api",
@@ -67,18 +85,27 @@
6785
"Tool": "Amazon.Lambda.Annotations",
6886
"SyncedEvents": [
6987
"RootPost"
70-
]
88+
],
89+
"SyncedEventProperties": {
90+
"RootPost": [
91+
"Path",
92+
"Method"
93+
]
94+
}
7195
},
7296
"Properties": {
73-
"Runtime": "dotnet6",
97+
"Architectures": [
98+
"x86_64"
99+
],
100+
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Query_Post_Generated::Post",
101+
"Runtime": "dotnet8",
74102
"CodeUri": ".",
75103
"MemorySize": 256,
76104
"Timeout": 30,
77105
"Policies": [
78106
"AWSLambdaBasicExecutionRole"
79107
],
80108
"PackageType": "Zip",
81-
"Handler": "CommandQuery.Sample.AWSLambda::CommandQuery.Sample.AWSLambda.Query_Post_Generated::Post",
82109
"Events": {
83110
"RootPost": {
84111
"Type": "Api",

samples/CommandQuery.Sample.AspNetCore.Tests/CommandQuery.Sample.AspNetCore.Tests.csproj

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
75
<IsTestProject>true</IsTestProject>
86
</PropertyGroup>
97

samples/CommandQuery.Sample.AspNetCore/CommandQuery.Sample.AspNetCore.csproj

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>enable</ImplicitUsings>
75
</PropertyGroup>
86

97
<ItemGroup>
108
<PackageReference Include="CommandQuery.AspNetCore" Version="3.0.0" />
11-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
9+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
1210
</ItemGroup>
1311

1412
<ItemGroup>

samples/CommandQuery.Sample.AspNetCore/Properties/launchSettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dotnetRunMessages": true,
1515
"launchBrowser": true,
1616
"launchUrl": "swagger",
17-
"applicationUrl": "https://localhost:7071;http://localhost:7070",
17+
"applicationUrl": "https://localhost:7070;http://localhost:7071",
1818
"environmentVariables": {
1919
"ASPNETCORE_ENVIRONMENT": "Development"
2020
}

samples/CommandQuery.Sample.AzureFunctions.Tests/CommandTests.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.IO;
21
using System.Text;
3-
using System.Threading.Tasks;
42
using CommandQuery.AzureFunctions;
53
using FluentAssertions;
64
using Microsoft.Azure.Functions.Worker;
@@ -28,7 +26,7 @@ public void SetUp()
2826
context.SetupProperty(c => c.InstanceServices, serviceProvider);
2927
ExecutionContext = context.Object;
3028

31-
Subject = new Command(serviceProvider.GetRequiredService<ICommandFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
29+
Subject = new Command(serviceProvider.GetRequiredService<ICommandFunction>());
3230
}
3331

3432
[Test]

samples/CommandQuery.Sample.AzureFunctions.Tests/QueryTests.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.IO;
31
using System.Text;
4-
using System.Threading.Tasks;
52
using CommandQuery.AzureFunctions;
63
using CommandQuery.Sample.Contracts.Queries;
74
using FluentAssertions;
@@ -30,7 +27,7 @@ public void SetUp()
3027
context.SetupProperty(c => c.InstanceServices, serviceProvider);
3128
ExecutionContext = context.Object;
3229

33-
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
30+
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>());
3431
}
3532

3633
[Test]
@@ -73,7 +70,7 @@ public void SetUp()
7370
context.SetupProperty(c => c.InstanceServices, serviceProvider);
7471
ExecutionContext = context.Object;
7572

76-
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
73+
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>());
7774
}
7875

7976
[Test]

samples/CommandQuery.Sample.AzureFunctions.Tests/ShouldExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Net;
22
using System.Text.Json;
3-
using System.Threading.Tasks;
43
using CommandQuery.Sample.Contracts;
54
using FluentAssertions;
65
using Microsoft.Azure.Functions.Worker.Http;

samples/CommandQuery.Sample.AzureFunctions.Tests/TestExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Text.Json;
2-
using System.Threading.Tasks;
32
using Microsoft.Azure.Functions.Worker.Http;
43

54
namespace CommandQuery.Sample.AzureFunctions.Tests
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
using CommandQuery.AzureFunctions;
22
using Microsoft.Azure.Functions.Worker;
33
using Microsoft.Azure.Functions.Worker.Http;
4-
using Microsoft.Extensions.Logging;
54

65
namespace CommandQuery.Sample.AzureFunctions
76
{
8-
public class Command
7+
public class Command(ICommandFunction commandFunction)
98
{
10-
private readonly ICommandFunction _commandFunction;
11-
private readonly ILogger _logger;
12-
13-
public Command(ICommandFunction commandFunction, ILoggerFactory loggerFactory)
14-
{
15-
_commandFunction = commandFunction;
16-
_logger = loggerFactory.CreateLogger<Command>();
17-
}
18-
19-
[Function("Command")]
9+
[Function(nameof(Command))]
2010
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "command/{commandName}")] HttpRequestData req, FunctionContext executionContext, string commandName) =>
21-
await _commandFunction.HandleAsync(commandName, req, _logger, executionContext.CancellationToken);
11+
await commandFunction.HandleAsync(commandName, req, null, executionContext.CancellationToken);
2212
}
2313
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>net8.0</TargetFramework>
45
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
56
<OutputType>Exe</OutputType>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
87
</PropertyGroup>
8+
99
<ItemGroup>
10+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1011
<PackageReference Include="CommandQuery.AzureFunctions" Version="3.0.0" />
11-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
12-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
13-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
12+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
13+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
15+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.3" />
16+
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
17+
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
1418
</ItemGroup>
19+
1520
<ItemGroup>
1621
<ProjectReference Include="..\CommandQuery.Sample.Contracts\CommandQuery.Sample.Contracts.csproj" />
1722
<ProjectReference Include="..\CommandQuery.Sample.Handlers\CommandQuery.Sample.Handlers.csproj" />
1823
</ItemGroup>
24+
1925
<ItemGroup>
2026
<None Update="host.json">
2127
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -25,7 +31,9 @@
2531
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2632
</None>
2733
</ItemGroup>
34+
2835
<ItemGroup>
2936
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
3037
</ItemGroup>
38+
3139
</Project>

samples/CommandQuery.Sample.AzureFunctions/Program.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
using CommandQuery.Sample.Handlers;
66
using CommandQuery.Sample.Handlers.Commands;
77
using CommandQuery.Sample.Handlers.Queries;
8+
using Microsoft.Azure.Functions.Worker;
89
using Microsoft.Extensions.DependencyInjection;
910
using Microsoft.Extensions.Hosting;
1011

1112
var host = new HostBuilder()
12-
.ConfigureFunctionsWorkerDefaults()
13+
.ConfigureFunctionsWebApplication()
1314
.ConfigureServices(ConfigureServices)
1415
.Build();
1516

@@ -23,6 +24,9 @@ public static partial class Program
2324
{
2425
public static void ConfigureServices(IServiceCollection services)
2526
{
27+
services.AddApplicationInsightsTelemetryWorkerService();
28+
services.ConfigureFunctionsApplicationInsights();
29+
2630
services
2731
//.AddSingleton(new JsonSerializerOptions(JsonSerializerDefaults.Web));
2832

0 commit comments

Comments
 (0)