Open mathewc opened 5 years ago
@fabiocav thoughts on the right fix for this? We're seeing this issue for APIs other than Warmup that we originally logged this for. I just logged https://github.com/Azure/azure-functions-host/issues/6826. The unfortunate workaround for that issue will be to do a manual service lookup as we did for the Warmup API.
@fabiocav @mathewc - Ping - any updates on this?
We face similar issue. .NET 6.0, Microsoft.NET.Sdk.Functions Version="4.1.3"
System.InvalidOperationException: No service for type 'Microsoft.Azure.WebJobs.Script.IScriptJobHost' has been registered.
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ServicesModelBinder.BindModelAsync(ModelBindingContext bindingContext)
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.FunctionInvocationMiddleware.Invoke(HttpContext context) in //src/WebJobs.Script.WebHost/Middleware/FunctionInvocationMiddleware.cs:line 40
at Datadog.Trace.ClrProfiler.CallTarget.Handlers.Continuations.TaskContinuationGenerator`3.ContinuationAction(Task previousTask, TTarget target, CallTargetState state)
at Microsoft.Azure.WebJobs.Script.WebHost.Middleware.ExceptionMiddleware.Invoke(HttpContext context) in //src/WebJobs.Script.WebHost/Middleware/ExceptionMiddleware.cs:line 27
There are several places in our code where we use
[FromServices]
to resolve a host level service. In certain situations, even if the action is marked [RequiresRunningHost] a null can be returned. In a recent pr here we worked around this for a particular API, with the follow up being to put in a general solution for this so we're doing this consistently across all actions.E.g. I'm seeing exceptions in production now for the new runtime scale endpoint (HostController.GetScaleStatus) due to this issue.