You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 5, 2026. It is now read-only.
asp.net core is refactor with generic host in aspnet/Hosting#1163 that has better support on DI and lifecycle management etc, but I do not see an integration for the ServiceFabric-AspnetCore.
the ask is to provide a ServiceFabricHost that implement IHost interface, to wrap the generic logic to register service type and also creating service instance.
here are specific difference for Service Fabric that deserve its own ServiceFabricHost:
different dependency scope of service instance level.
Host scope (Singleton)
-- Service instance scope (* unique for Service Fabric)
---Request scope
----Transient scope
different execution and lifecycle for IHostedService.
for regular console host, the IHostedService shall be started right after host start; but for Service Fabric, it shall be registered with service factory and won't start the IHostedService directly; All IHostedService will be started as part of ICommunicationListener.OpenAsync; and IHostedService could be started multiple times within the same process, each time whenever there is a new service instance created.
here are sample scenario usage:
publicstaticclassServiceFabricHostBuilderExtension{publicstaticIHostBuilderUseServiceFabricHost(thisIHostBuilderhostBuilder,stringServiceTypeName);publicstaticIHostBuilderConfigureWebHost(thisIHostBuilderhostBuilder,Action<HostBuilderContext,IWebHostBuilder>configureWebHost);}/// <summary>/// This is the entry point of the service host process./// </summary>privatestaticvoidMain(){varbuilder=newHostBuilder();// required, register service factory with ServiceFabricHostbuilder.UseServiceFabricHost("TestHttpServiceType");// config WebHostbuilder.ConfigureWebHost((context,webHostBuilder)=>// the same native Startup experience from WebHostwebHostBuilder.UseKestrel()// config to use Kestrel or HttpSys.UseStartup<Startup>()// further extension with standard asp.net core Startup extension.);// optional, standard DI injection, injection here will be used in both host and service instancebuilder.ConfigureServices(sc =>{});builder.ConfigureAppConfiguration(sc =>{});// configuration that will be applied to service instance.builder.ConfigureLogging(loggingBuilder =>{});// optional to config additional logging.// required, run the service until cancelled or abortedbuilder.Build().Run();}
asp.net core is refactor with generic host in aspnet/Hosting#1163 that has better support on DI and lifecycle management etc, but I do not see an integration for the ServiceFabric-AspnetCore.
the ask is to provide a ServiceFabricHost that implement IHost interface, to wrap the generic logic to register service type and also creating service instance.
here are specific difference for Service Fabric that deserve its own ServiceFabricHost:
-- Service instance scope (* unique for Service Fabric)
---Request scope
----Transient scope
for regular console host, the IHostedService shall be started right after host start; but for Service Fabric, it shall be registered with service factory and won't start the IHostedService directly; All IHostedService will be started as part of ICommunicationListener.OpenAsync; and IHostedService could be started multiple times within the same process, each time whenever there is a new service instance created.
here are sample scenario usage: