Unable to load .NET config sections into System.Configuration classes within an aws lambda function

418 Views Asked by At

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

1

There are 1 best solutions below

0
On

I think the link provided by John Wu answers the question fairly well: https://github.com/aws/aws-lambda-dotnet/issues/230

In short, the fact that AWS lambdas does not play nice with ConfigurationManager is unlikely to change, even though all of that works fine when run locally.