Skip to content

Commit 0a17672

Browse files
committed
💁
1 parent ebb105c commit 0a17672

File tree

23 files changed

+111
-108
lines changed

23 files changed

+111
-108
lines changed

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

Lines changed: 2 additions & 2 deletions
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>
Lines changed: 5 additions & 5 deletions
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
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
@@ -13,17 +13,17 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Amazon.Lambda.Annotations" Version="1.1.0" />
16+
<PackageReference Include="Amazon.Lambda.Annotations" Version="1.5.0" />
1717
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
18-
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
18+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.3" />
1919
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.0" />
2020
<PackageReference Include="CommandQuery.AWSLambda" Version="3.0.0" />
21-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
21+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
2222
</ItemGroup>
2323

2424
<ItemGroup>
2525
<ProjectReference Include="..\CommandQuery.Sample.Contracts\CommandQuery.Sample.Contracts.csproj" />
2626
<ProjectReference Include="..\CommandQuery.Sample.Handlers\CommandQuery.Sample.Handlers.csproj" />
2727
</ItemGroup>
2828

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

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

Lines changed: 4 additions & 4 deletions
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+
}
Lines changed: 16 additions & 17 deletions
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

Lines changed: 37 additions & 10 deletions
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/CommandQuery.Sample.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="CommandQuery.AspNetCore" Version="3.0.0" />
11-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
11+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void SetUp()
2828
context.SetupProperty(c => c.InstanceServices, serviceProvider);
2929
ExecutionContext = context.Object;
3030

31-
Subject = new Command(serviceProvider.GetRequiredService<ICommandFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
31+
Subject = new Command(serviceProvider.GetRequiredService<ICommandFunction>());
3232
}
3333

3434
[Test]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void SetUp()
3030
context.SetupProperty(c => c.InstanceServices, serviceProvider);
3131
ExecutionContext = context.Object;
3232

33-
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
33+
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>());
3434
}
3535

3636
[Test]
@@ -73,7 +73,7 @@ public void SetUp()
7373
context.SetupProperty(c => c.InstanceServices, serviceProvider);
7474
ExecutionContext = context.Object;
7575

76-
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>(), serviceProvider.GetRequiredService<ILoggerFactory>());
76+
Subject = new Query(serviceProvider.GetRequiredService<IQueryFunction>());
7777
}
7878

7979
[Test]
Lines changed: 3 additions & 13 deletions
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
}
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>net8.0</TargetFramework>
45
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
56
<OutputType>Exe</OutputType>
67
<ImplicitUsings>enable</ImplicitUsings>
78
<Nullable>enable</Nullable>
89
</PropertyGroup>
10+
911
<ItemGroup>
12+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1013
<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" />
14+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
15+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
16+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
17+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.3" />
18+
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
19+
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
1420
</ItemGroup>
21+
1522
<ItemGroup>
1623
<ProjectReference Include="..\CommandQuery.Sample.Contracts\CommandQuery.Sample.Contracts.csproj" />
1724
<ProjectReference Include="..\CommandQuery.Sample.Handlers\CommandQuery.Sample.Handlers.csproj" />
1825
</ItemGroup>
26+
1927
<ItemGroup>
2028
<None Update="host.json">
2129
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -25,7 +33,9 @@
2533
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2634
</None>
2735
</ItemGroup>
36+
2837
<ItemGroup>
2938
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
3039
</ItemGroup>
40+
3141
</Project>

samples/CommandQuery.Sample.AzureFunctions/Program.cs

Lines changed: 5 additions & 1 deletion
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

Lines changed: 3 additions & 13 deletions
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 Query
7+
public class Query(IQueryFunction queryFunction)
98
{
10-
private readonly IQueryFunction _queryFunction;
11-
private readonly ILogger _logger;
12-
13-
public Query(IQueryFunction queryFunction, ILoggerFactory loggerFactory)
14-
{
15-
_queryFunction = queryFunction;
16-
_logger = loggerFactory.CreateLogger<Query>();
17-
}
18-
19-
[Function("Query")]
9+
[Function(nameof(Query))]
2010
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "query/{queryName}")] HttpRequestData req, FunctionContext executionContext, string queryName) =>
21-
await _queryFunction.HandleAsync(queryName, req, _logger, executionContext.CancellationToken);
11+
await queryFunction.HandleAsync(queryName, req, null, executionContext.CancellationToken);
2212
}
2313
}

samples/CommandQuery.Sample.AzureFunctions/host.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"samplingSettings": {
66
"isEnabled": true,
77
"excludedTypes": "Request"
8-
}
8+
},
9+
"enableLiveMetricsFilters": true
910
}
1011
}
11-
}
12+
}

samples/CommandQuery.Sample.Client/CommandQuery.Sample.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
<ItemGroup>
99
<PackageReference Include="CommandQuery.Client" Version="3.0.0" />
10-
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
10+
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.7" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\CommandQuery.Sample.Contracts\CommandQuery.Sample.Contracts.csproj" />
1515
</ItemGroup>
1616

17-
</Project>
17+
</Project>

0 commit comments

Comments
 (0)