Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HostApplicationBuilder Extension Support #3062

Open
RyanThomas73 opened this issue Mar 1, 2024 · 0 comments
Open

HostApplicationBuilder Extension Support #3062

RyanThomas73 opened this issue Mar 1, 2024 · 0 comments

Comments

@RyanThomas73
Copy link

RyanThomas73 commented Mar 1, 2024

Feature Request

Currently the webjobs SDK only provides extensions to configure webjob services against the older IHostBuilder types.
Support should be added for configuring the webjobs against the newer IHostApplicationBuilder type as well to ensure developers can leverage that latest .NET features and development practices.

Related information

Current WebJobHostBuilderExtensions Source Location

The HostApplicationBuilder Documentation Page

The Related Host.CreateApplicationBuilder Documenation Page

See also this comment from the dotnet runtime repository regarding the plans for switching to the newer application builder signatures

Minimal Implementation Example

public static IWebJobsBuilder ConfigureWebJobs(
    this IHostApplicationBuilder builder)
    => ConfigureWebJobs(builder, static jobHostOptions => { });
    
public static IWebJobsBuilder ConfigureWebJobs(
    this IHostApplicationBuilder builder,
    Action<JobHostOptions> configure)
{
    builder.Configuration.TryAddDefaultConfigurationSources();

    var webJobsBuilder = builder.Services.AddWebJobs(configure);
    builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, JobHostService>());

    return webJobsBuilder;
}
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

No branches or pull requests

1 participant