NL.Serverless.AspNetCore.AzureFunctionsHost 5.1.0

dotnet add package NL.Serverless.AspNetCore.AzureFunctionsHost --version 5.1.0                
NuGet\Install-Package NL.Serverless.AspNetCore.AzureFunctionsHost -Version 5.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NL.Serverless.AspNetCore.AzureFunctionsHost" Version="5.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NL.Serverless.AspNetCore.AzureFunctionsHost --version 5.1.0                
#r "nuget: NL.Serverless.AspNetCore.AzureFunctionsHost, 5.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NL.Serverless.AspNetCore.AzureFunctionsHost as a Cake Addin
#addin nuget:?package=NL.Serverless.AspNetCore.AzureFunctionsHost&version=5.1.0

// Install NL.Serverless.AspNetCore.AzureFunctionsHost as a Cake Tool
#tool nuget:?package=NL.Serverless.AspNetCore.AzureFunctionsHost&version=5.1.0                

NL.Serverless.AspNetCore

This repo provides code for hosting an AspNet Core App inside an Azure Function V3 HTTP Trigger with the new isolated worker.

Prerequisites

  1. Will to use the new isolated dotnet worker for functions (see the repo)
  2. .Net Core SDK >= 5.0.4
  3. Latest Azure Function Core Tools v3
npm install -g azure-functions-core-tools@3

Instructions

  1. Install the project template for dotnet and create a new project.
dotnet new --install NL.Serverless.AspNetCore.Template
dotnet new serverless-aspnetcore -n Your.New.ProjectName
  1. Happy coding your AspNet Core WebApp.
  2. Run the Azure Function hosting the web app
func host start -build

Deployment to Azure

  1. Follow this instruction: https://github.com/Azure/azure-functions-dotnet-worker#create-the-azure-resources

  2. Create an app setting within the function app.

    The name of the setting should be ASPNETCORE_TEST_CONTENTROOT_NAME_OF_YOUR_WEBAPP_ASSEMBLY and point the value to C:\home\site\wwwroot\

    image

Quirks

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

Application Insights / Logs

In order to see the logs of the Asp.Net Core app inside the log stream of Application Insights from the functions app you need to add the following lines:

  1. Add the package reference of Microsoft.ApplicationInsights.AspNetCore to the .csproj of your web app

    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.17.0" />

  2. Register the Applications Insights services in the Statup.cs of your web app

    services.AddApplicationInsightsTelemetry();
    

Please note that Application Insights has it´s own logging levels configured in the appsettings.json. You can find the documentation here.

Here is an example:

  ...
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    },
    "ApplicationInsights": {
      "LogLevel": {
        "Default": "Information"
      }
    }
  },
  ...

If you want to use another instance of Application Insights for the web app you need to add the Instrumation Key in the appsettings.json:

   ...
      "ApplicationInsights": {
        "InstrumentationKey": "putinstrumentationkeyhere"
      },
   ...

Samples

Host the ASP.NET Boilerplate sample in an Azure Function

Credits

The basic idea for this is from this repo: https://github.com/NicklausBrain/serverless-core-api

Thanks <a href="https://github.com/NicklausBrain">NicklausBrain</a>.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.1.0 3,425 8/26/2021
5.0.0 361 4/12/2021
3.0.11 1,103 1/30/2021
3.0.9 571 7/31/2020
3.0.8 545 7/8/2020
3.0.7.2 11,123 6/13/2020
3.0.7.1 546 5/25/2020
3.0.7 458 5/9/2020
3.0.5 465 3/20/2020
3.0.3 449 1/30/2020