Azure / Azure/azure-functions-host

Can't create EventGrid V3 function from the portal after switch to ~3 Preview

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

Description

1. Create a function app.
2. Switch Runtime version to "3 Preview".
3. Create an EventGrid function:

Request URL: https://management.azure.com/subscriptions/xxx/resourceGroups/alrod-v3/providers/Microsoft.Web/sites/alrod-v3-JS/functions/EventGridTrigger1?api-version=2018-11-01
Request Method: PUT
Status Code: 400

{"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from host runtime.","Target":null,"Details":[{"Message":"Encountered an error (InternalServerError) from host runtime."},{"Code":"BadRequest"},{"ErrorEntity":{"Code":"BadRequest","Message":"Encountered an error (InternalServerError) from host runtime."}}],"Innererror":null}
4. Click on create button second time and the function is created.

Host stacktrace:
```
System.InvalidOperationException : Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at System.Linq.ImmutableArrayExtensions.First[T](ImmutableArray`1 immutableArray,Func`2 predicate)
at async Microsoft.Azure.WebJobs.Script.WebHost.Management.WebFunctionsManager.TryGetFunction(String name,HttpRequest request) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Management\WebFunctionsManager.cs : 167
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Management.WebFunctionsManager.CreateOrUpdate(String name,FunctionMetadataResponse functionMetadata,HttpRequest request) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Management\WebFunctionsManager.cs : 153
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.CreateOrUpdate(String name,FunctionMetadataResponse functionMetadata) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Controllers\FunctionsController.cs : 75
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper,ObjectMethodExecutor executor,Object controller,Object[] arguments)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.ValueTask`1.get_Result()
at async Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next,Scope& scope,Object& state,Boolean& isCompleted)
at async Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
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 async Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(??)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.FunctionInvocationMiddleware.Invoke(HttpContext context) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\FunctionInvocationMiddleware.cs : 52
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Middleware.DefaultMiddlewarePipeline.<>c.b__7_0(??) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\JobHostMiddleware\DefaultMiddlewarePipeline.cs : 31
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Middleware.HstsConfigurationMiddleware.<>c.<-ctor>b__1_0(??) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\HstsConfigurationMiddleware.cs : 24
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Middleware.HstsConfigurationMiddleware.Invoke(HttpContext context,RequestDelegate next) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\HstsConfigurationMiddleware.cs : 42
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Middleware.DefaultMiddlewarePipeline.<>c__DisplayClass8_1.b__1(??) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\JobHostMiddleware\DefaultMiddlewarePipeline.cs : 45
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.CustomHttpHeadersMiddleware.Invoke(HttpContext context,RequestDelegate next) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\CustomHttpHeadersMiddleware.cs : 34
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Middleware.DefaultMiddlewarePipeline.<>c__DisplayClass8_1.b__1(??) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\JobHostMiddleware\DefaultMiddlewarePipeline.cs : 45
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.JobHostPipelineMiddleware.Invoke(HttpContext httpContext,IJobHostMiddlewarePipeline middleware) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\JobHostPipelineMiddleware.cs : 26
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.ResponseContextItemsCheckMiddleware.Invoke(HttpContext context) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\ResponseContextItemsCheckMiddleware.cs : 29
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.HomepageMiddleware.Invoke(HttpContext context) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\HomepageMiddleware.cs : 34
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.Middleware.ExceptionMiddleware.Invoke(HttpContext context) at C:\azure-functions-host\src\WebJobs.Script.WebHost\Middleware\ExceptionMiddleware.cs : 28
```

Contributor guide

Open the contributing guide

Research direction

Start in WebJobs.Script.WebHost/Management/WebFunctionsManager.cs at TryGetFunction, especially line 167, then inspect CreateOrUpdate and FunctionsController.CreateOrUpdate. Reproduce the portal flow with the 3 Preview runtime and EventGrid function creation. Done means the first creation request succeeds without the Sequence contains no elements error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.