-
Notifications
You must be signed in to change notification settings - Fork 198
Description
Describe the issue
Added openapi support in a .net 6 isolated azure function. During opening the swagger from http://localhost:7071/api/swagger/ui
its throwing exception Microsoft.AspNetCore.Http.Internal.QueryCollection' from assembly 'Microsoft.AspNetCore.Http
To Reproduce
Steps to reproduce the behavior:
-
Add nuget packages "Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.0"
-
Add in Program.cs file
.ConfigureFunctionsWorkerDefaults(worker =>
{
worker.UseNewtonsoftJson();
})
.ConfigureOpenApi(); -
Added
OpenApiOperation
attribute to functions -
Run the application
-
Once call
http://localhost:7071/api/swagger/ui
, see error
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your issue.
Environment (please complete the following information, if applicable):
- OS: Windows
- Browser: chrome
- Version: v1.5.0: Update
Additional context
- Completed stack trace are below : [2023-01-10T09:14:14.687Z] Azure Functions .NET Worker (PID: 17344) initialized in debug mode. Waiting for debugger to attach...
[2023-01-10T09:14:19.641Z] Host lock lease acquired by instance ID '0000000000000000000000001FFDC842'.
[2023-01-10T09:14:24.142Z] Executing 'Functions.RenderSwaggerUI' (Reason='This function was programmatically called via the host APIs.', Id=325d290b-bdb2-4dba-a670-c4a896a2006d)
[2023-01-10T09:14:32.755Z] Worker process started and initialized.
[2023-01-10T09:14:33.131Z] SwaggerUI page was requested.
[2023-01-10T09:14:33.201Z] Executed 'Functions.RenderSwaggerUI' (Failed, Id=325d290b-bdb2-4dba-a670-c4a896a2006d, Duration=9077ms)
[2023-01-10T09:14:33.203Z] System.Private.CoreLib: Exception while executing function: Functions.RenderSwaggerUI. System.Private.CoreLib: Result: Failure
Exception: System.AggregateException: One or more errors occurred. (Could not load type 'Microsoft.AspNetCore.Http.Internal.QueryCollection' from assembly 'Microsoft.AspNetCore.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.)
[2023-01-10T09:14:33.203Z] ---> System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Internal.QueryCollection' from assembly 'Microsoft.AspNetCore.Http, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[2023-01-10T09:14:33.204Z] at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Extensions.OpenApiHttpRequestDataExtensions.Queries(HttpRequestData req)
[2023-01-10T09:14:33.204Z] at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.HttpRequestObject..ctor(HttpRequestData req)
[2023-01-10T09:14:33.205Z] at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.Functions.OpenApiTriggerFunction.RenderSwaggerUI(HttpRequestData req, FunctionContext ctx)
[2023-01-10T09:14:33.206Z] at Microsoft.Azure.Functions.Worker.Extensions.OpenApi.DefaultOpenApiHttpTrigger.RenderSwaggerUI(HttpRequestData req, FunctionContext ctx)
[2023-01-10T09:14:33.206Z] --- End of inner exception stack trace ---
[2023-01-10T09:14:33.207Z] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[2023-01-10T09:14:33.209Z] at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) [2023-01-10T09:14:33.211Z] at System.Threading.Tasks.Task
1.get_Result()
[2023-01-10T09:14:33.212Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker2.<>c.<InvokeAsync>b__6_0(Task
1 t) in D:\a_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32
[2023-01-10T09:14:33.215Z] at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() [2023-01-10T09:14:33.216Z] at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj) [2023-01-10T09:14:33.218Z] at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) [2023-01-10T09:14:33.219Z] --- End of stack trace from previous location --- [2023-01-10T09:14:33.221Z] at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) [2023-01-10T09:14:33.223Z] --- End of stack trace from previous location --- [2023-01-10T09:14:33.233Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 44 [2023-01-10T09:14:33.238Z] at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13 [2023-01-10T09:14:33.243Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a\_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 82 Stack: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [2023-01-10T09:14:33.248Z] at System.Threading.Tasks.Task
1.GetResultCore(Boolean waitCompletionNotification)
[2023-01-10T09:14:33.250Z] at System.Threading.Tasks.Task1.get_Result() [2023-01-10T09:14:33.253Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker
2.<>c.b__6_0(Task1 t) in D:\a\_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 32 [2023-01-10T09:14:33.255Z] at System.Threading.Tasks.ContinuationResultTaskFromResultTask
2.InnerInvoke()
[2023-01-10T09:14:33.266Z] at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
[2023-01-10T09:14:33.270Z] at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
[2023-01-10T09:14:33.272Z] --- End of stack trace from previous location ---
[2023-01-10T09:14:33.273Z] at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
[2023-01-10T09:14:33.275Z] --- End of stack trace from previous location ---
[2023-01-10T09:14:33.278Z] at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 44
[2023-01-10T09:14:33.280Z] at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
[2023-01-10T09:14:33.283Z] at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 82.