Setting the file. One moment.
Subchapter 21.108
references/services/functions/templates/recipes/common/dotnet-entry-point.mdMarkdown2 KBView on GitHub
The base Azure Functions template includes a properly configured Program.cs that should NOT be modified or replaced by recipes.
⛔ CRITICAL: Do NOT replace or modify Program.cs from the base template.
The official functions-quickstart-dotnet-azd template uses:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication() // ASP.NET Core integration
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
host.Run();| Feature | ConfigureFunctionsWebApplication | ConfigureFunctionsWorkerDefaults |
|---|---|---|
| ASP.NET Core integration | ✅ Yes | ❌ No |
| IActionResult return types | ✅ Yes | ❌ No |
| [FromBody] model binding | ✅ Yes | ❌ No |
| App Insights integration | ✅ Built-in | ❌ Manual setup |
| Modern HTTP handling | ✅ Yes | ⚠️ Limited |
Recipes only need to add:
.cs files with [Function] attributes).csproj additions for extensions)All triggers use attribute-based binding — no Program.cs modifications needed:
[HttpTrigger], [TimerTrigger], [CosmosDBTrigger][ServiceBusTrigger], [EventHubTrigger], [BlobTrigger][DurableClient], [SqlTrigger]❌ WRONG — Recipe overwrites Program.cs with outdated version:
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults() // OLD PATTERN
.Build();✅ CORRECT — Recipe leaves Program.cs untouched, only adds function files.