简体   繁体   中英

Azure Functions v2 changed from .Net Standard to .Net Core

I have been using Azure Functions for the last month and have been happily creating them as V2 (.Net Standard)

Problem

Now after the most recent update I can only create V2 as (.Net Core), and these don't seem to be compatible with the old type.

Question

Do I really need to port all my old functions into this new type? This is the error I get when trying to reference a new function in an old function.

Project is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project supports: netcoreapp2.0 (.NETCoreApp,Version=v2.0)

Screenshot of both V2 projects side by side.

在此处输入图片说明

For now, netstandard2.0(old template for a long time) and netcoreapp2.1(updated several days ago) target framework both work. The function runtime 2.x is based on .Net Core env from the very beginning so this TF change should have no effect on functions built before, just offer access to .Net Core APIs and related dependencies.

But we can't reference projects targeting at different framework, we have to change TF to achieve compatibility. Right click on project and Edit <FunctionProjectName>.csproj .

在此处输入图片说明

See default TF in new template. (Update VS to latest 15.8.8 to consume latest .Net Core 2.1.)

<PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>

We can modify new project back to TF netstandard2.0, but I recommend to update old projects to netcoreapp2.1 for long term compatibility. Remember to update Microsoft.NET.Sdk.Functions to 1.0.* (ie the latest) in old projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM