tntwist / NL.Serverless.AspNetCore

Hosting an AspNet Core App inside an Azure Function V3 HTTP Trigger
MIT License
20 stars 3 forks source link

.net 5/Functions worker support? #34

Closed alastairtree closed 3 years ago

alastairtree commented 3 years ago

Azure functions have started setting out how they will support .net5.0+ with a new worker based model. You can run net 5 functions in preview now by following this sample app https://github.com/Azure/azure-functions-dotnet-worker-preview. "function 5" in the demo is closest to the use case users of this repo might be interested in. In addition, MS have open sourced the worker code itself this time round at https://github.com/Azure/azure-functions-dotnet-worker.

From what I can tell it looks like a full rewrite with a similar, but different and breaking, API. It no longer depends on the same HttpRequest types for example. It probably requires similar levels of rewrite for current apps which depend on NL.Serverless.AspNetCore to give them a migration path to .net5+.

So thought I would open this issue to give it some visibility and see if anyone else had any interest in that sort of work?

tntwist commented 3 years ago

I already played a bit with the new worker preview: https://github.com/tntwist/NL.Serverless.AspNetCore/tree/net-5

Currently I struggle with getting a HttpRequest into the Asp.Net Core WebApp, since the function provides HttpRequestData. Thanks for providing the source of the worker code. Didn´t noticed MS had open sourced it. Maybe I can find something useful that helps getting the request into the WebApps.

It probably requires similar levels of rewrite for current apps which depend on NL.Serverless.AspNetCore to give them a migration path to .net5+.

I hope that the changes can be limited to creating a Program.cs, removing the Startup in the FuntionApp, changing some dependencies and minor changes to the ProxyFunction.

tntwist commented 3 years ago

Hi, I got this working. You can use the Version 5.0.0 with the new isolated functions worker.

Changes are pretty limited:

  1. Update your FunctionApp to isolated worker.
  2. Delete the Startup of your FunctionApp. It´s not needed any more.
  3. Add the following line to the configuration of the IHostBuilder in the Program.cs of the FunctionApp: .ConfigureWebAppFunctionHost<WebApp.Startup>()
  4. Make sure your WebAppProxy Function takes HttpRequestData as input an returns HttpReponseData. It should look like this

SignalR currently only works with Long Pooling as transport method. Either connect with this transport method client side or configure your Hubs to just support Long Pooling (see here).

I only updated the library right now. The template for the .net cli will follow soon.

alastairtree commented 3 years ago

Great news, thank you.

On Thu, 1 Apr 2021, 23:27 Nico L., @.***> wrote:

Hi, I got this working. You can use the Version 5.0.0 with the new isolated functions worker.

Changes are pretty limited:

  1. Update your FunctionApp to isolated worker.
  2. Delete the Startup of your FunctionApp. It´s not needed any more.
  3. Add the following line to the configuration of the IHostBuilder in the Program.cs of the FunctionApp: .ConfigureWebAppFunctionHost()
  4. Make sure your WebAppProxy Function takes HttpRequestData as input an returns HttpReponseData. It should look like this https://github.com/tntwist/NL.Serverless.AspNetCore/blob/master/src/NL.Serverless.AspNetCore.FunctionApp/WebAppProxyFunction.cs

SignalR currently only works with Long Pooling as transport method. Either connect with this transport method client side or configure your Hubs to just support Long Pooling (see here https://docs.microsoft.com/de-de/aspnet/core/signalr/configuration?view=aspnetcore-5.0&tabs=dotnet#advanced-http-configuration-options ).

I only updated the library right now. The template for the .net cli will follow soon.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tntwist/NL.Serverless.AspNetCore/issues/34#issuecomment-812208920, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABP3TFLPLFB2ME4LA7WIGHDTGTXOTANCNFSM4XSBS7QQ .

tntwist commented 3 years ago

Just released the new version in Nuget. You can use it now. 😄