Mike Pennington
Mike Pennington

Reputation: 676

Is it possible to publish a .net core web api to azure functions?

I've recently switched jobs from a AWS shop to an Azure shop, both using dotnet. AWS publishes Amazon.Lambda.AspNetCoreServer, which is a magic Nuget package that allows you to write a plain ol' ASP.NET core Web API and deploy it as into a lambda with only a few lines on config. I really loved this pattern because it allows developers to just write a normal web api without having the host runtime leak into their coding.

Does anything like this exist in Azure? Even something that is community supported? Or is there some any way to achieve something like this in Azure Functions?

Upvotes: 3

Views: 2039

Answers (1)

Vova Bilyachat
Vova Bilyachat

Reputation: 19514

Unfortunately there is no simple way to do that since Azure function format is a bit different.

[FunctionName(nameof(GetAll))]
public IActionResult GetAll([HttpTrigger("get", Route = "entity")]HttpRequest request)

Then it will generate json with meta data for AF.

If you wish to host pure .net core without any changes I would look into Containers option

PS0: Theoretically it would be possible to do it with little bit of reflection. For instance you create project with all your Asp.Net core apis, which you can use in asp.net core hosting. Then you write tool which grabs your dll and using reflection you find all actions in your controllers and generate code for AF

PS1: Have a look https://github.com/tntwist/NL.Serverless.AspNetCore

Upvotes: 5

Related Questions