Azure Function v2 .NET framework?

2020-04-08 01:56发布

问题:

We currently have deployed a V1 Azure Function and are looking to upgrade this to V2[preview]. However I can't see any way to target .NET Framework 4.6.1 at the moment, only .NET Core when creating a v2 function.

Is it possible use .NET Framework in Azure Function v2?

回答1:

The Function Runtime in v2 only runs on .NET Core 2.0, so there is no way to target .NET Framework 4.6.1.



回答2:

Using Visual Studio 2017 Preview 2, I was able to create a 4.61 Azure Functions Library.

<PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

My full csproj

PLEASE NOTE (future readers) this is subject to change as time goes by and the "preview" becomes integrated into the "real" VS2017.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs" Version="2.1.0-beta1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="2.1.0-beta1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="1.0.0-beta1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.1.0-beta1" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.0-alpha3" />
    <PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.2" />
    <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
    <PackageReference Include="Unity" Version="4.0.1" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>