Azure / Azure/azure-functions-host
Migrate from IHostBuilder to HostApplicationBuilder / WebApplicationBuilder APIs
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
### Background
The Functions host currently uses `new HostBuilder()` (returning `IHostBuilder`) with `ConfigureWebHostDefaults` and `UseStartup()`. The modern `HostApplicationBuilder` / `WebApplicationBuilder` APIs are the recommended
hosting model going forward.
### Current state
- `Program.CreateHostBuilder()` returns `IHostBuilder`
- Web host setup uses `ConfigureWebHostDefaults` + `UseStartup()`
- Test infrastructure chains `IHostBuilder` extension methods (`ConfigureWebHost`, `ConfigureScriptHostServices`, etc.)
### Proposed change
Replace `new HostBuilder()` + `ConfigureWebHostDefaults` + `UseStartup` with `WebApplication.CreateEmptyBuilder()` and the minimal hosting model.
### Scope
| Area | Work required |
|------|--------------|
| `Program.cs` | Replace `IHostBuilder` construction with `WebApplicationBuilder` / `WebApplication` |
| `Startup.cs` | Inline `ConfigureServices` and `Configure` into `Program.cs`; `UseStartup` is not supported on the new builder |
| Test infrastructure | Update `TestFunctionHost`, `EndToEndTestFixture`, `StandbyManagerE2ETestBase`, and ~50+ integration test call sites that chain `IHostBuilder` extensions |
| Custom extensions | Provide new overloads or adapt `ConfigureScriptHostServices` and similar `IHostBuilder` extensions |
### Benefits
- Aligns with the modern recommended hosting pattern
- Simpler service/config registration (direct property access vs callbacks)
- Better integration with minimal API patterns for future modernization
### Notes
- No expected performance difference, this is a modernization change.
- Functional behavior must remain identical.
- Validate with perflab CI runs to confirm no regression.
Contributor guide
Assessment
This issue has not been assessed yet.