Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load appsettings.json files in isolated functions app #2908

Open
jpoalaska opened this issue Dec 20, 2024 · 1 comment
Open

Unable to load appsettings.json files in isolated functions app #2908

jpoalaska opened this issue Dec 20, 2024 · 1 comment

Comments

@jpoalaska
Copy link

Description

I'm running an isolated worker function on .net 9 using the asp.net core integration configuration and I'm trying to get appsettings files to load. When I call builder.Configuration.AddJsonFile(filepath, false) I get an exception:

The configuration file 'appsettings.test.json' was not found and is not optional. The expected physical path was '/tmp/functions\\standby\\wwwroot/appsettings.test.json'.\n at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)\n at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource source)\n at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(IConfigurationSource source)\n at Program.<Main>$(String[] args)

Did something change from .net 8 to 9 or maybe in the new Microsoft.Azure.Functions.Worker 2.0 package? I don't think I understand what's happening with this /tmp/functions\standby folder.

@jpoalaska
Copy link
Author

jpoalaska commented Dec 20, 2024

My workaround for now until I understand what I'm doing wrong

var binDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
builder
    .AddJsonFile(Path.Combine(binDirectory, "appsettings.json")) 
    .AddJsonFile(Path.Combine(binDirectory, $"appsettings.{environment}.json"), false);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant