【问题标题】:What parts of ASP.NET does Azure Functions use?Azure Functions 使用 ASP.NET 的哪些部分?
【发布时间】:2018-12-12 06:32:13
【问题描述】:

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

【问题讨论】:

    标签: azure azure-functions azure-functions-runtime


    【解决方案1】:

    两个概念,一个是支持 Azure Functions 的主机/运行时。

    目前,Azure Function 2.0 运行时基于.Net Core 2.1,并引用Microsoft.AspNetCore.App v2.1.6

    另一个是 Azure WebJobs SDK,该框架简化了编写代码以在 Azure Function 运行时上运行的任务。我们可以使用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

    【讨论】:

      【解决方案2】:

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

      您的函数必须针对由 dotnet core 2.0 (https://docs.microsoft.com/en-us/dotnet/standard/net-standard) 实现的 .NET Standard 2.0

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-09
        • 2018-04-19
        • 2018-06-16
        • 2020-04-21
        • 2020-04-30
        • 1970-01-01
        • 2017-10-29
        • 1970-01-01
        相关资源
        最近更新 更多