Azure / Azure/azure-functions-host

Migrate from IHostBuilder to HostApplicationBuilder / WebApplicationBuilder APIs

Open
#11,737 0 comments 0 reactions 1 assignee Claimed by @kshyju View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.