Skip to content

feat: add Action overloads to ConfigureFunctionsWebApplication for FunctionsApplicationBuilder#3349

Open
MO2k4 wants to merge 4 commits intoAzure:mainfrom
MO2k4:feature/issue-3052-configure-functions-web-application-overloads
Open

feat: add Action overloads to ConfigureFunctionsWebApplication for FunctionsApplicationBuilder#3349
MO2k4 wants to merge 4 commits intoAzure:mainfrom
MO2k4:feature/issue-3052-configure-functions-web-application-overloads

Conversation

@MO2k4
Copy link

@MO2k4 MO2k4 commented Mar 16, 2026

Summary

  • Adds Action<IFunctionsWorkerApplicationBuilder> and Action<HostBuilderContext, IFunctionsWorkerApplicationBuilder> overloads to FunctionsApplicationBuilderAspNetCoreExtensions, mirroring the existing IHostBuilder API in FunctionsHostBuilderExtensions
  • Both overloads delegate through FunctionsApplicationBuilder.HostBuilder — zero duplicated logic; idempotency and ASP.NET Core integration guards continue to run through the single existing implementation
  • Includes null guards (ArgumentNullException.ThrowIfNull) on the callback parameters

Fixes #3052

Test Plan

  • 3 new tests added: action callback, context+action callback, idempotency (service descriptor count + callback invocation count)
  • All 26 tests pass (dotnet test test/extensions/Worker.Extensions.Http.AspNetCore.Tests/)
  • Build clean: 0 errors, 0 warnings on net6.0 and net8.0

…nctionsApplicationBuilder

Adds Action<IFunctionsWorkerApplicationBuilder> and Action<HostBuilderContext, IFunctionsWorkerApplicationBuilder>
overloads to FunctionsApplicationBuilderAspNetCoreExtensions, mirroring the existing IHostBuilder API.

Fixes Azure#3052
Copy link
Member

@kshyju kshyju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @MO2k4 Change looks good to me. One minor suggestion about including exception information in the summary document. I noticed the existing method does not throw and handle null input gracefully. But it is okay for this new method to throw when argument is null.

/// <returns>The <see cref="FunctionsApplicationBuilder"/> for chaining.</returns>
public static FunctionsApplicationBuilder ConfigureFunctionsWebApplication(this FunctionsApplicationBuilder builder, Action<IFunctionsWorkerApplicationBuilder> configureWorker)
{
ArgumentNullException.ThrowIfNull(configureWorker);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we update the method summary to document what exception is being thrown? (Use <exception cref="ArgumentNullException">)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint, i've added it

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ConfigureFunctionsWebApplication overloads on FunctionsApplicationBuilder that accept worker configuration callbacks, enabling scenarios (e.g., F# / .NET Aspire) that need to imperatively configure the worker pipeline without reflecting into the internal HostBuilder.

Changes:

  • Added Action<IFunctionsWorkerApplicationBuilder> and Action<HostBuilderContext, IFunctionsWorkerApplicationBuilder> overloads to FunctionsApplicationBuilderAspNetCoreExtensions.
  • Delegated both overloads through FunctionsApplicationBuilder.HostBuilder to reuse the existing IHostBuilder implementation (including idempotency/guards).
  • Added new unit tests covering callback invocation, context propagation, and idempotent registrations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/Worker.Extensions.Http.AspNetCore/src/FunctionsApplicationBuilderAspNetCoreExtensions.cs Adds the new overloads and delegates to the existing host-builder-based implementation.
test/extensions/Worker.Extensions.Http.AspNetCore.Tests/FunctionsApplicationBuilderAspNetCoreExtensionsTests.cs Adds tests validating the new overloads and idempotent service registration behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kshyju kshyju requested a review from Copilot March 18, 2026 14:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Action-based overloads for ConfigureFunctionsWebApplication on FunctionsApplicationBuilder to mirror the existing IHostBuilder API, along with tests validating callbacks and idempotent registrations.

Changes:

  • Added Action<IFunctionsWorkerApplicationBuilder> and Action<HostBuilderContext, IFunctionsWorkerApplicationBuilder> overloads that delegate to builder.HostBuilder.
  • Added tests covering action callback, context callback, and idempotency of ASP.NET Core integration service registrations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
test/extensions/Worker.Extensions.Http.AspNetCore.Tests/FunctionsApplicationBuilderAspNetCoreExtensionsTests.cs Adds new unit tests for the new overloads and idempotent registrations.
extensions/Worker.Extensions.Http.AspNetCore/src/FunctionsApplicationBuilderAspNetCoreExtensions.cs Introduces new overloads with null guards that delegate to existing host-builder integration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +62 to +65
private static void VerifyRegistrationOfCustomMiddleware(IHost host)
{
Assert.NotNull(host.Services.GetService<TestMiddleware>());
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the middleware is directly registered before this assertion this looks like a false positive to me.

underTest.ConfigureFunctionsWebApplication(builder => builder.UseMiddleware());

@MO2k4
Copy link
Author

MO2k4 commented Mar 18, 2026

@kshyju I've updated the release notes as well, if you want to take a look


### Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore <version>

- Add `Action<IApplicationBuilder>` overloads to `ConfigureFunctionsWebApplication` for `FunctionsApplicationBuilder` (#3052) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This release notes file is for the worker packages. Since you are making changes to the aspnetcore extension package, the changelog entry should go to https://github.com/Azure/azure-functions-dotnet-worker/blob/main/extensions/Worker.Extensions.Http.AspNetCore/release_notes.md file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry i have not seen this

@kshyju
Copy link
Member

kshyju commented Mar 19, 2026

@kshyju I've updated the release notes as well, if you want to take a look

Thanks! Can you also review the feedback from GHCP review and address them?

@MO2k4 MO2k4 force-pushed the feature/issue-3052-configure-functions-web-application-overloads branch from 066e041 to a32c44f Compare March 19, 2026 15:31
- Strengthen idempotency test with GetServices<T>() to detect duplicate
  registrations post-build
- Fix TestMiddleware to call next(context) instead of short-circuiting
@MO2k4
Copy link
Author

MO2k4 commented Mar 19, 2026

@kshyju I've checked the three comments by ghcp and adapted two, the first looks like a false positive to me, because it is handled directly before the assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ConfigureFunctionsWebApplication extension allowing to pass configure action

3 participants