Unable to load .NET config sections into System.Configuration classes within an aws lambda function
I would like to deploy an AWS lambda function using .NET Core. Much of the code is shared with other applications that are not lambdas. We use System.Configuration extensively throughout our code. However, we are unable to get lambda code to find and load configuration files.
These are snippets from our application config file.
<configSections>
<sectionGroup name="countryConfig">
<section name="countryConfiguration"
type="TTDomain.Configuration.Countries.CountryConfiguration, TTDomain_NETStandard"/>
</sectionGroup>
<configSections>
...
...
<countryConfig>
<countryConfiguration configSource="Web.countryConfiguration.config"/>
</countryConfig>
And then in C# code we do things like
public static CountryConfiguration GetConfig()
{
return ConfigurationManager.GetSection("countryConfig/countryConfiguration") as CountryConfiguration;
}
This all works just fine, except when deployed as a lambda function. We have many many such usages of various configurations throughout a large code base of assemblies shared to many contexts. Not being able to use this very basic .NET feature is creating a lot of re-work. Any ideas how to make it work without needing to touch all our C# code?
Thanks
Hi Kevin,
I suspect the issue is that you are using the Windows Compatibility Pack to leverage ConfigurationManager from your .NET Core application. Whilst the Windows Compatibility Pack makes it easy to port .NET Framework apps to .NET, it restricts those applications to only run on Windows. AWS Lambda is underpinned by Linux which means .NET Core applications that have Windows dependencies won't work.
Relevant questions
RDS Proxy on MySQL Lambda Function (C# .Net Core 3.1 Runtime)
asked 4 months agoLamba url + .net core api, how to remove duplicate cors 'Access-Control-Allow-Origin'
Accepted Answerasked a month agois it possible that SQS Triggers to a Lambda Function Alias?
Accepted Answerasked 3 months agoScheduling local lambda function
asked a year ago[Issue] Lambda LexEvent returns "null" values from Lex v2 Request
asked 3 months agoDeny request in Cognito Pre Authentication lambda using dot net core
asked 3 years agoLambda .net 5 container not an option in aws toolkit blueprints
asked 3 months agoStart & Stop of EC2 instance using tags in Lambda function
Accepted Answerasked 2 months agoUnable to load .NET config sections into System.Configuration classes within an aws lambda function
asked a month agoTextract AnalyseId not working / available on Lambda
Accepted Answerasked 4 months ago