Azure Functions 使用 ASP.NET 的哪些部分?

What parts of ASP.NET does Azure Functions use?

Azure Functions 使用 ASP.NET(核心?)中的 HttpResultIActionResult 类 来处理 HTTP 触发器。 Azure Functions v2 运行时的 ASP.NET 是哪个版本?我知道 v2 在 .NET Core 上使用 .NET Standard 2.0 运行,所以我假设使用了 ASP.NET Core,但哪个版本?

根据 https://github.com/Azure/Azure-Functions/issues/686#issuecomment-389699549 Azure Functions 不支持框架的概念,但支持 .NET Standard 接口。

您的函数必须以 .NET Standard 2.0 为目标,它由 dotnet core 2.0 (https://docs.microsoft.com/en-us/dotnet/standard/net-standard)

实现

另请参阅 https://github.com/dotnet/standard/milestone/3 - .NET Standard 2.1 不可用或即将发布。

两个概念,一个是为 Azure Functions 提供支持的 host/runtime。

现在,Azure Function 2.0 运行时间基于 .Net Core 2.1, and references Microsoft.AspNetCore.App v2.1.6

另一个是 Azure WebJobs SDK,该框架简化了在 Azure Function 运行 上向 运行 编写代码的任务 运行time。我们可以使用 HttpResultIActionResult 因为 SDK 引用 ASP.NET(Core) packages.

<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.4" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.1.0" />  
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.1.0" />

而我们的 Function 项目可以针对 netcoreapp2.1netstandard2.0。要使用 .Net Core API,请使用 netcoreapp2.1.