DEV Community

Jeff Hollan for Microsoft Azure

Posted on • Updated on

Develop Azure Functions using .NET Core 3.1

<< Updated on Dec 9 2019 with go-live announcement of Azure Functions on .NET Core 3.1 >>

We're extremely excited to announce you can now develop and publish Azure Functions built on top of the .NET Core 3.1 runtime.

Things to know

Azure Functions 3.0 is now go-live and ready for production. It is a highly backwards compatible release. One of the immediate benefits of this release is you can write Azure Functions targeting netcoreapp3.1. You should also be able to move existing ~2 apps to ~3 without issue. A list of considerations on changes between 2.x and 3.x can be found in our docs.

You can write any Azure Function language in 3.0 (Java, JavaScript, PowerShell, TypeScript, Python) - though note some of the tooling and integrations will continue to receive updates until mid-January. Instructions on changing your tools or apps to target 3.x for other languages can be found in our docs. For now let's walk through creating a .NET Core 3.1 app.

Getting started

Install the .NET Core 3.1 SDK

Install the 3.x core tools (optional for Visual Studio development)

Using npm:

npm install -g azure-functions-core-tools@3
Enter fullscreen mode Exit fullscreen mode

Using brew:

brew tap azure/functions
brew install azure-functions-core-tools@3
# If you already have func installed
brew link --overwrite azure-functions-core-tools@3
Enter fullscreen mode Exit fullscreen mode

Create an Azure Functions project

You have a few options here. You could create a new project using our Visual Studio, Visual Studio Code, or CLI tools. For other tools, once you install the 3.x core tools you should be set. If attempting to target .NET Core 3.1 just be sure to update your .csproj file template with netcoreapp3.1. Also be sure to target the `Microsoft.NET.Sdk.Functions package version of at least 3.0.1.

Creating with Visual Studio 2019

If you want to develop using .NET Core 3.1, you must use Visual Studio 2019 16.4 or newer.

  1. Open Visual Studio and select to create a new Azure Functions project
    • You should see an indicator at the bottom as it downloads the runtime and templates of "Making sure all templates are up to date." This could take a few minutes, but wait for it to finish.
  2. Once the templates are up to date, go back one screen and forward so template options are refreshed.
  3. Select the now available "Azure Functions v3" option from the template drop-down.
  4. Create your project.
  5. If you want to target .NET Core 3.1, edit the project properties and select .NET Core 3.1.

You should be set! You can now debug, test, and publish this function.

Publish your Function App

You can publish your function using the regular tools. Depending on the tool you will likely see a prompt to update your FUNCTIONS_EXTENSION_VERSION application setting from the default ~2 to ~3. This does need to occur before a 3.x app can run successfully in Azure.

Upgrading a v2 app to v3

If you have an existing app and want to test it out with the new release, the following settings would need to be modified:

Non-.NET Functions

Locally once you start using the 3.x CLI your apps will debug and run in the 3.0 environment automatically. For apps in the cloud, you simply need to update the app setting of FUNCTIONS_EXTENSION_VERSION to ~3 - but make sure to do some validation tests first before changing anything in production 😅.

.NET Functions

If using Visual Studio, make sure you've already followed all of the steps in the "Creating with Visual Studio 2019" section to ensure you have the latest templates and project options available before attempting to upgrade. You may need to go to the new app template screen to get the 3.x bits to pull in on your machine, so if you get an error like "no runtime available that matches the version," try creating a new 3.x app from scratch first to make sure VS has fetched all the latest bits.

To change a project between ~2 and ~3 locally, update the .csproj file of the project and change:

  • AzureFunctionsVersion from v2 to v3
  • Microsoft.NET.Sdk.Functions package version to at least 3.0.1
  • Optionally, you can change to target netcoreapp3.1 if you want to target the latest .NET Core version

You should not change the host.json version to 3.0. The host.json schema version is different than the function runtime version, and is still 2.0.

Path to GA

While you can begin using 3.x in production today, we are tracking a few work items around tooling and platform features before we announce full GA for tools and runtime in January 2020. You can see some of those work items called out in GitHub

Oldest comments (61)

Collapse
 
ma3yta profile image
Andrii Maksymets

Can I use F# or do you have templates for it?

Collapse
 
jeffhollan profile image
Jeff Hollan

Yep! Have a few templates you can install via NuGet and dotnet cli here github.com/Azure/azure-functions-t... or VS Code will list and use if you select to view “All” templates github.com/microsoft/vscode-azuref...

Collapse
 
andreasjakof profile image
Andreas Jakof • Edited

\o/
Good news, can't wait until .NET Core 3.0 is available everywhere in Azure, without having to install additional extensions.

Collapse
 
hamedsayy profile image
Hamed • Edited

Hi,
I get these errors in this preview:
Microsoft.Data.SqlClient is not supported on this platform.
System.Drawing is not supported on this platform.

Collapse
 
jakobgsvendsen profile image
Jakob G. Svendsen

+1

Collapse
 
jeffhollan profile image
Jeff Hollan • Edited

Can you let me know the package you are pulling in that is causing this, and how you are using it? Any steps I can take to repro would be great.

Thread Thread
 
mswilson4040 profile image
Marc

I created an issue on GitHub. I'm getting the same thing. My suspicion is that it's coming from Entity Framework

github.com/Azure/Azure-Functions/i...

Thread Thread
 
hamedsayy profile image
Hamed

issue comes from Microsoft.EntityFrameworkCore.SqlServer when calls DB.
System.Drawing also in any call will get error.

Thread Thread
 
mswilson4040 profile image
Marc

Do you know of a workaround / fix?

Thread Thread
 
mswilson4040 profile image
Marc

Someone got back to me on my GitHub Issue (github.com/Azure/Azure-Functions/i...) with a workaround that fixes this.

Thread Thread
 
jakobgsvendsen profile image
Jakob G. Svendsen

Sorry for not getting back to you earlier" been super busy in ignite planning! Great to see there is a workaround. Will test it ASAP!

Thread Thread
 
jeffhollan profile image
Jeff Hollan

Not sure where this landed but as an FYI just tested using both Entity Framework and SQL server on v3 bits and worked fine. Here's my repo: github.com/jeffhollan/functions-ch...

Thread Thread
 
hamedsayy profile image
Hamed

3.1 works perfectly. Good job.

Collapse
 
mrsimonc profile image
Mr Simon C

Came across this post by sheer luck last night - and tried it out. Works great! I can confirm Azure Function v3 with Microsoft Graph Auth works really well. Also really nice to use Null coalescing assignment and in-built Json Serializer. May I never have to hear "Newtonsoft" by choice ever again ;)

Collapse
 
acethecloud profile image
Abhishek @ Ace The Cloud

The Git Repository that this Azure Fx package mentioned nuget.org/packages/Microsoft.NET.S...

is not having code related to 1.0.30-beta2 , and neither in Release section of git repo 1.0.30-beta2 is mentioned as Released.

github.com/Azure/azure-functions-v... , in branches there is branch for beta1 but not for beta2 , not sure why it is so ?

Collapse
 
zpittmansf profile image
zpittmansf

I was able to see the preview in the drop down yesterday but today I cannot. I posted an issue on github github.com/Azure/azure-functions-h....

Collapse
 
colbytresness profile image
Colby Tresness

Update to the latest Visual Studio 2019 preview if you're still having this issue.

Collapse
 
zpittmansf profile image
zpittmansf

Thanks, I am not but hopefully they fix this mapping problem of versions before it gets out of preview ;)

Collapse
 
zpittmansf profile image
zpittmansf

Another way to get around this is just running the version of func.exe that you want. You can do this by changing the debug settings of the csproj to
C:\Users\xxxx\AppData\Local\AzureFunctionsTools\Releases\3.0.2\cli\func.exe and a parameter of start.

Collapse
 
mckabue profile image
Kabue Charles

Error generating functions metadata because of Microsoft.AspNetCore.Mvc.Abstractions, Version=3.0.0.0 , see: github.com/Azure/azure-functions-v...

Collapse
 
avishar profile image
Vijay

The main issue we have is that it’s incompatible with net standard 2.1.

If function project A exposes a class from net standard project B, when B is 2.0 everything works, when B is 2.1 the solution won’t even compile anymore.

This issue has been blocking since release with no comment from maintainers, are you able to have someone look into it?

Collapse
 
doogdeb profile image
doogdeb

When trying to pull in a netcore3.0 logging component we've written, it complains with the following.

Error System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method)
at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error)
at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable1 types)+MoveNext()
at System.Collections.Generic.List
1.AddEnumerable(IEnumerable1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source)
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()

Error generating functions metadata
Logging.UserAgent C:\Users\user.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets 41

Collapse
 
jdaless profile image
John D'Alessandro • Edited

I'm having trouble building a v3-preview project in my DevOps Git repo CI pipeline. Despite applying all of the upgrade steps you gave it's still looking for a Microsoft.NETCore.App 2.1.0 framework. dotnet build works locally. Deployment also works locally, and I have my function app running just fine, but not having CI/CD is a bottleneck.

Collapse
 
patricknolan profile image
Patrick • Edited

Hi John I'm encountering the same issue. Did you find a solution?

It is compiling and running in my dev environment using .NET Core 3.0 but behind my Azure build Pipeline I get the following error

It was not possible to find any compatible framework version [/home/vsts/work/1/s/blah.csproj]
error : The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found.
error : - The following frameworks were found: [/home/vsts/work/1/s/blah.csproj]
error : 3.0.0 at [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]
error : [/home/vsts/work/1/s/blah.csproj]

Collapse
 
jeffhollan profile image
Jeff Hollan

Was able to repro. Found a bug. Tracked here: github.com/Azure/azure-functions-v...

workaround is to make sure 2.x is on the build box as well. I changed my deploy script to this and it worked in the interim.

- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '2.1.x'
- task: UseDotNet@2
  inputs:
    packageType: 'sdk'
    version: '3.0.x'
Collapse
 
miguelesteban profile image
miguelEsteban

+1

Collapse
 
colbytresness profile image
Colby Tresness

Update to the latest Visual Studio 2019 preview if you're still having this issue.

Collapse
 
jagge123 profile image
jagge123

Did all the steps above and still no sign of Azure Functions v3 Preview - option in the drop down. Any ideas?

Collapse
 
colbytresness profile image
Colby Tresness

You're likely not on the latest VS 2019 Preview. What version are you using?

Collapse
 
sjscheidertt profile image
sjscheider-tt

I had this working for a couple weeks now. After an OS update, I think that is the culprit, I'm getting the following error when I try to run any functions is Visual Studio.

"There is no Functions runtime available that matches the version specified in the project"

Collapse
 
sjscheidertt profile image
sjscheider-tt

A co-working of mine was able to figure this one out with the assistance of this link:
github.com/Azure/azure-functions-t...

In the file feed.json (C:\Users\[user]\AppData\Local\AzureFunctionsTools\feed.json): it defines all capable versions you can debug in VS.
The feed.json updates automatically and for some reason the information for v3-preview disappeared for both my co-worker and I.

So we just "hardcoded" the executable path under Properties > Debug for the project.
Set the executable to: C:\Users\[user]\AppData\Local\AzureFunctionsTools\Releases\3.0.3\cli\func.exe
Set application arguments to: start

Collapse
 
smartymind profile image
Smartymind • Edited

Thanks for this updated information about what visual studio must be used. Maybe it is our fault behavior but we was not checking this article everyday so we did not get this notice before we updated visual studio to newest version therefore the development has stopped. Do you have any idea how could we install a specific version of visual studio 2019 community? I've found only links to professional and enterprise versions here.

Collapse
 
colbytresness profile image
Colby Tresness

Hey there - we're really sorry that we had to make this change. Unfortunately it was necessary in order to prevent breaking old versions of Visual Studio once we take the experience out of preview. We don't expect it will happen again.

This should help: docs.microsoft.com/en-us/visualstu...

Collapse
 
smartymind profile image
Smartymind

This link did not help.

Collapse
 
smimon profile image
smimon

After running "npm install -g azure-functions-core-tools@preview", I do not have version 3 available in the C:\Users[User]\AppData\Local\AzureFunctionsTools\Releases folder - highest version is still 2.42.0

Any ideas how to pull in the preview version? Thanks

Collapse
 
smimon profile image
smimon

Never mind, I found instructions on how to download it manually from here github.com/Azure/azure-functions-t...