Hello, I'm working with an AzureFunction(CosmosDBTrigger), everything was working ok but suddenly the function stop working. When I want to Run the function I got the following errors:

my host.json:
{
"version": "2.0",
"logging":
{
"applicationInsights":
{
"samplingSettings":
{
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
my local.settings.json:
{
"IsEncrypted": false,
"Values":
{
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"UseDevelopmentStorage": true,
"IS_RUNNING_LOCALLY": "true",
"DatabaseName": "myDbName",
"CosmosDBConnection": "myCosmosConnection",
"CosmosDbEndpointUri": "https://localhost:8081",
...
}
}
Program.cs:
public static class Program{
static void Main() {
var assembly = Assembly.GetExecutingAssembly();
var host = new HostBuilder()
.ConfigureAppConfiguration(builder => { builder.AddUserSecrets(assembly, true); })
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services => { services.AddMyCollectionServices(assembly); })
.Build();
host.Run();
}
}
In my IServiceCollection file:
...
var isRunningLocally = Environment.GetEnvironmentVariable("IS_RUNNING_LOCALLY") == "true";
var configuration = BuildConfiguration(isRunningLocally, assembly);
...
private static IConfigurationRoot BuildConfiguration(bool isRunningLocally, Assembly assembly){
var configurationBuilder = new ConfigurationBuilder();
if (isRunningLocally){
configurationBuilder
.AddJsonFile("local.settings.json", optional: true)
.AddUserSecrets(assembly, true);
}
var configuration = configurationBuilder.Build();
return configuration;
}
My function.csproj
...
...
When I debug the IServiceCollection the line where I intent to get from the "local.settings.json" the value "IS_RUNNING_LOCALLY" it always resolve as false, which means that Environment.GetEnvironmentVariable("IS_RUNNING_LOCALLY") is not able to read the value of that property.
I have spend couple hours trying to figure it out but I can't find what could possibly cause the error. As I said before this function was working just fine and suddenly stop working. Besides that I have another CosmosDbTrigger with the exact same project and configuration structure and it is working fine.