Open thomas-parikka-milliman opened 1 month ago
@thomas-parikka-milliman Good afternoon. Apologies for the delayed reply. I wasn't able to reproduce the issue on Windows (even though your environment say Mac) using the similar code as above, but with below package references and AWS .NET 8.0 Mock Lambda Test Tool (0.15.3)
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Generate ready to run images during publishing to improve cold start time. -->
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.2.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.1" />
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
</ItemGroup>
</Project>
Below is launchSettings.json
in my Windows environment:
{
"profiles": {
"Mock Lambda Test Tool": {
"commandName": "Executable",
"commandLineArgs": "--port 5050",
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe",
"environmentVariables": {
"ENVIRONMENT": "local"
}
}
}
}
The error is thrown by var configurationBuilder = new ConfigurationBuilder().AddEnvironmentVariables();
, it appears unrelated to test tool.
Please share the following:
var configurationBuilder = new ConfigurationBuilder().AddEnvironmentVariables();
for Serilog configuration during startup. Could your please elaborate?Thanks, Ashish
This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.
Describe the bug
I am attempting to write a Lambda that requires Serilog to be configured during startup. In order to do this I am using the following code in my main Function class relying on environment variables:
When I step over the first line, the ConfigurationBuilder returned has thrown a
System.ArgumentException
. When I step over the second line the call toBuild()
returns aSystem.ArrayTypeMismatchException
. For testing, I removed even the call toAddEnvironmentVariables()
with no improvement. I reproduced the example in a brand new Lambda project using the SQS template.I have tested a similar config setup in a basic .NET BackgroundService with no issues.
Regression Issue
Expected Behavior
I expect the ConfigurationBuilder to be able to load environment variables into memory for use later in the application.
Current Behavior
The newly created ConfigurationBuilder throws System.ArgumentException on all properties. Building the ConfigurationBuilder produces a System.ArrayTypeMismatchException.
Reproduction Steps
Function.cs:
launchSettings.json
csproj
aws-lambda-tools-defaults
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Amazon.Lambda.Serialization.SystemTextJson 2.4.3 Amazon.Lambda.Core 2.3.0 Amazon.Lambda.SQSEvents 2.2.0 AWSSDK.Extensions.NETCore.Setup 3.7.301
Targeted .NET Platform
.NET 8
Operating System and version
MacOS Sequoia 15.0.1