NL.Serverless.AspNetCore.Template
3.0.11
See the version list below for details.
dotnet new install NL.Serverless.AspNetCore.Template@3.0.11
NL.Serverless.AspNetCore
This repo provides code for hosting an AspNet Core App inside an Azure Function V3 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 <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
- .Net Core SDK >= 3.1.100
- Azure Function Core Tools v3
npm install -g azure-functions-core-tools@3
Instructions
- 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
- Happy coding your AspNet Core WebApp.
- Run the Azure Function hosting the web app
func host start -build
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:
Add the package reference of
Microsoft.ApplicationInsights.AspNetCoreto the .csproj of your web app<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.14.0" />Register the Applications Insights services in the
Statup.csof your web appservices.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>.
-
.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 | 1,441 | 8/26/2021 |
| 5.0.0 | 2,714 | 4/12/2021 |
| 3.0.11 | 1,107 | 1/30/2021 |
| 3.0.9 | 1,123 | 7/31/2020 |
| 3.0.8 | 1,106 | 7/8/2020 |
| 3.0.7.2 | 1,080 | 6/13/2020 |
| 3.0.7.1 | 1,149 | 5/25/2020 |
| 3.0.7 | 1,108 | 5/9/2020 |
| 3.0.5 | 1,109 | 3/20/2020 |
| 3.0.3 | 1,160 | 1/30/2020 |
| 3.0.2 | 1,170 | 1/12/2020 |
| 1.0.2 | 1,132 | 10/20/2019 |
| 1.0.1 | 1,130 | 10/17/2019 |
| 1.0.0 | 1,141 | 10/13/2019 |