Azure / Azure/azure-functions-host

Out-of-Proc host regression: Intermittently host startup fails due to services and instance count mismatch during child container creation

Open
#11,752 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

Standard logic app function host startup fails due to error
System.InvalidOperationException : Mismatch detected for type Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryContext:
services.Count = 2, instances.Count = 0
Services:
ServiceType: Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryContext Lifetime: Singleton ImplementationInstance: Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryContext,
ServiceType: Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryContext Lifetime: Singleton ImplementationInstance: Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryContext
Instances:

at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ServiceProviderExtensions.ValidateServiceAndInstanceCounts[TService,TInstance](TService[] servicesArray,TInstance[] instancesArray,Type serviceType) at /_/src/WebJobs.Script.WebHost/DependencyInjection/ServiceProviderExtensions.cs : 164
at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.ServiceProviderExtensions.CreateChildContainer(IServiceProvider serviceProvider,IServiceCollection serviceCollection) at /_/src/WebJobs.Script.WebHost/DependencyInjection/ServiceProviderExtensions.cs : 113
at Microsoft.Azure.WebJobs.Script.WebHost.DependencyInjection.JobHostScopedServiceProviderFactory.CreateServiceProvider(IServiceCollection services) at /_/src/WebJobs.Script.WebHost/DependencyInjection/JobHostScopedServiceProviderFactory.cs : 68
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.UnsynchronizedStartHostCoreAsync(ScriptHostStartupOperation activeOperation,Int32 attemptCount,JobHostStartupMode startupMode) at /_/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs : 394

Image

#### Investigative information

Please provide the following:

- Timestamp: 2026-04-28 00:01:20.2272393 to 2026-04-28 00:03:24.2272393
- Function App version: V4
- Function App name: pravagareastusisolatedhosttestp2
- Function name(s) (as appropriate):
- Invocation ID:
- Region:

#### Repro steps

Provide the steps required to reproduce the problem:

1. Create a logic app standard in EastUS2 EUAP region.
2. Add an app setting LOGICAPP_USE_ISOLATED_HOST=1 so that logic app uses out-of-proc function host is used.
3. Create few workflows. Try restarting the app multiple times. It can be observed that sometime app is not started and in error state with exception provided above. Function logs has all error details.
4. Try restarting again. The app stays healthy.

#### Expected behavior

On restart, app should be in healthy state consistently.

Contributor guide

Open the contributing guide

Research direction

Start with src/WebJobs.Script.WebHost/DependencyInjection/ServiceProviderExtensions.cs, especially CreateChildContainer and ValidateServiceAndInstanceCounts, then follow JobHostScopedServiceProviderFactory.CreateServiceProvider. Reproduce repeated restarts of a Logic App Standard app using LOGICAPP_USE_ISOLATED_HOST=1 and compare the service and instance collections. Done means the out-of-proc host starts consistently without the mismatch exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.