I have a function and I want to inject my classes in the Program.cs. But it doesn’t seem to start the program.cs.
Here is my program.cs:
var host = new HostBuilder()
.ConfigureAppConfiguration((hostContext, configBuilder) =>
{
configBuilder.AddJsonFile("local.settings.json", true, true);
})
.ConfigureFunctionsWorkerDefaults()
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddConsole();
})
.ConfigureServices((hostContext, services) =>
{
var connectionString = hostContext.Configuration.GetConnectionString("incontrol");
services.AddDbContext<DataContext>(options => { options.UseSqlServer(connectionString); });
})
.Build();
host.Run();
In the functions.csproj I already set this:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
When I set a breakpoint in program.cs this is not triggerd and I get error that the services are not injected.
What Am I missing here?