2

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.

enter image description here

2
  • 1
    I don't know how Azure Functions work exactly, but generally speaking there should be no code changes required, only changing the target from netstandard2.0 to netcoreapp2.0 Commented Oct 26, 2018 at 14:02
  • I cannot change the target from netstandard2.0 to netcoreapp2.0. I only get a list of either but not both within the same project. Commented Oct 26, 2018 at 14:28

1 Answer 1

3

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.

enter image description here

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.*(i.e. the latest) in old projects.

Sign up to request clarification or add additional context in comments.

2 Comments

@JerryLiu do I understand correctly that using the netcore is the common recommedation now? What advantages does it give? And doesn't referencing netstandard mean that it'll work for core 2.1, 2.2 etc.automatically while all those implement the standard? What I am trying to say is, doesn't specifying the standard imply we can forget about upgrading the TF, while specifying the core implies we should explicitly change the TF in order to upgrade?
@AndreyStukalin The TF change is mainly to support usage of .net core APIs. If it's not necessary we could just stay with netstandard2.0 and forget about upgrading the TF. As for the upgrade from net core 2.1 to higher, I assume the back forward compatibility would be achieved for Azure Function otherwise it would be a breaking change to many existing projects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.