NL.Serverless.AspNetCore.Template 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet new install NL.Serverless.AspNetCore.Template::1.0.1
This package contains a .NET Template Package you can call from the shell/command line.

NL.Serverless.AspNetCore

This repo provides code for hosting an AspNet Core App inside an Azure Function V2 HTTP Trigger without the use of TestServer.

I combined the solution of <a href="https://github.com/NicklausBrain">NicklausBrain</a> (original repo can be found <a href="https://github.com/NicklausBrain/serverless-core-api">here</a>) with the recently added <a href="https://docs.microsoft.com/en-US/azure/azure-functions/functions-dotnet-dependency-injection">DI support for azure functions</a>. This provides a way to avoid initalizing the AspNet Core App with every incoming request.

Prerequisites

  1. .Net Core SDK 2.2.402 (Azure Functions don´t support .Net Core 3.0 yet)
  2. Latest Azure Function Core Tools
npm install -g azure-function-core-tools

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

Visual Studio 2019 16.3/.Net SDK 3.0 Quirk

Currently you wont be able to build the function project in VS2019 16.3. (<a href="https://developercommunity.visualstudio.com/content/problem/748109/vs2019-163-azure-functions-tools-fails-build-due-t.html">Related bug report</a>)

The reason is that the generation of the function.json fails due to missing assemblies. I think this is caused by the .Net Core 3.0 SDK, since the dotnet.exe is called for creating the function.json.

I created a global.json for the project to force the .Net SDK Version to 2.2.402. With this workaround you should be able to atleast build and run the function app using the core tools.

func host start -build

After you started the function app you can attach the Visual Studio Debugger to the func.exe and start debugging your code in Visual Studio.

Credits

Most of the code is copy pasta from this repo: https://github.com/NicklausBrain/serverless-core-api

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

  • .NETStandard 2.0

    • No dependencies.

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 703 8/26/2021
5.0.0 2,091 4/12/2021
3.0.11 491 1/30/2021
3.0.9 502 7/31/2020
3.0.8 443 7/8/2020
3.0.7.2 460 6/13/2020
3.0.7.1 519 5/25/2020
3.0.7 487 5/9/2020
3.0.5 476 3/20/2020
3.0.3 532 1/30/2020
3.0.2 519 1/12/2020
1.0.2 495 10/20/2019
1.0.1 484 10/17/2019
1.0.0 496 10/13/2019