Azure / Azure/Azure-Functions

Using a settings file with a different name is not working.

Open
#2,412 3 comments 0 reactions 1 assignee Claimed by @bhagyshricompany View on GitHub
v4-bug
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

Function App name: microServiceBus.functions
Tools used: VS2022 - Version 17.4.4 & Version 17.7.4
.Net runtime: 6
Runtime: dotnet-isolated
Language: C#
Core Tools Version: 4.0.5390 Commit hash: N/A (64-bit)
Function Runtime Version: 4.25.3.21264

We have an function app used by many customers, hence we've had to updated the `local.settings.json` dependin on which the customer we've been working with. Upon migrating from v4 In-proc to v4 isolated we've instead created multiple settings files, one for each customer as this has worked fine for our web applications. However, using a settings file with a different name is not working.

```csharp
var host = new HostBuilder()
.ConfigureAppConfiguration((context, config) => {
//config.AddJsonFile("local.settings.json", optional: true);
config.AddJsonFile("local.settings.CUSTOMER.json", optional: true);

config.AddEnvironmentVariables();
})
ConfigureLogging(logging => ...)
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices((context, services) => ...)
.Build();

host.Run();
```
Behavior:
If the `local.settings.json` does not exist, the process will not start with the following error:
```bash
Azure Functions Core Tools
Core Tools Version: 4.0.5390 Commit hash: N/A (64-bit)
Function Runtime Version: 4.25.3.21264

Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell, --custom]
[2023-10-06T10:30:41.620Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.IncidentHandler_SendEmail'. Microsoft.Azure.WebJobs.Host:
```
Interestingly, it seams the configuration is evaluated before the `ConfigureAppConfiguration` method is executed, as if I set a breakpoint in the method I can se the output of funciton list before the breakpoint is hit.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.