DEV Community

Develop Azure Functions using .NET Core 3.1

Jeff Hollan on October 17, 2019

<< 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 ...
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
 
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
 
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
 
andreasohlund profile image
Andreas Öhlund

Are there any known issues with app insights when running locally?

Previously I could inject a TelemetryConfiguration into my function but since updating to v3 from the preview it blows up with:

Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type 'Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration'

Not tested if this works when publishing though.

Collapse
 
jeffhollan profile image
Jeff Hollan

No known issue but I imagine this is due to in conflicting with its own configuration and potentially something changed between versions. I’d open up a GitHub issue for this one

Collapse
 
eliashdezr profile image
Elias Hdez • Edited

Overall, dependency injection issues has been since the .NET Core 3.0 release. Can you follow up this please?

github.com/Azure/azure-functions-d...

and this

github.com/Azure/azure-functions-d...

Collapse
 
andreasohlund profile image
Andreas Öhlund

Thanks, raised github.com/Azure/azure-functions-h... , seems to be more ppl with the same issue.

Collapse
 
andreasohlund profile image
Andreas Öhlund

Ie this no longer works locally docs.microsoft.com/en-us/azure/azu...

Collapse
 
patricknolan profile image
Patrick • Edited

Hi Jeff,

I have followed your article and my solution is compiling and running in my dev environment using .NET Core 3.0 but behind my Azure build Pipeline I get the following error. Could you please offer any suggestions?

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

Your app is set to target 2.1 so your build agent will need a 2.x version. Reads that build agent only has 3.x. Other option is change app target is csproj to netcoreapp3.0

Collapse
 
patricknolan profile image
Patrick

Hi Jeff thanks heaps for your response it hugely appreciated!

My .csproj file currently contains the following. Would you then expect the Azure build pipeline to target 3.0 and not 2.1?


netcoreapp3.0
v3-preview

Thread Thread
 
jeffhollan profile image
Jeff Hollan

Hmm if that’s what your csproj says maybe the problem is the other way around. Can you confirm the devops agent has and is using dotnet 3? I don’t know where the 2.1 would come from if it’s not in your csproj file

Thread Thread
 
patricknolan profile image
Patrick • Edited

I'm executing a "use .NET Core" step beforehand which is set to version 3.0.x. I noticed John D'Alessandro also posted here with the same issue :(

I also tried setting the Agent Specification to windows-2019 value as suggested here stackoverflow.com/questions/565741...

Thread Thread
 
jeffhollan profile image
Jeff Hollan

Ok let me see if I can repro

Thread Thread
 
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
 
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
 
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
 
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
 
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
 
markatagilliance profile image
Mark Davies

Cautionary note. I had a working function and re-factored to put one of the function service dependencies in its own .net standard library. It stopped working.

If you get an error like
FunctionApp1: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Then you may be missing the crucial step I missed : setting the AzureFunctionsVersion from v2 to v3-preview in the project file. It worked as V2 as a single project function and only stopped working when I separated the injected dependency service into its own library. HTH.

Collapse
 
felicss profile image
felicss

Did this actually solve the problem for you? I am still getting the same error, even with v3-preview

Collapse
 
felicss profile image
felicss

Fixed it => the latest preview-release of the Microsoft.EntityFrameworkCore 3.1.0-preview3 seems to cause the problem

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...

Collapse
 
cmendibl3 profile image
Carlos Mendible

Hi Jeff is there a preview version of the Docker image so I can update my mcr.microsoft.com/azure-functions/dotnet:2.0 refs?

Collapse
 
zpertee20 profile image
zach pertee

Ditto. I also badly need this feature. Can I simply update my dockerfile to install .net core 3 or is there more to it than that?

Collapse
 
jeffhollan profile image
Jeff Hollan

We have them published mcr.microsoft.com/azure-functions/...

Thread Thread
 
zpertee20 profile image
zach pertee

Thanks Jeff!

Thread Thread
 
cmendibl3 profile image
Carlos Mendible

Thanks dude!

Collapse
 
chartloginc profile image
Chartlog

After spending the entire day to try to get this working I have finally given up. I was in the midst of trying to automate my ef migrations using azure pipelines and ran into an issue where generated migration scripts would have syntactical issues described here

github.com/aspnet/EntityFrameworkC...

This led me to upgrade to ef core 3, which led me down a cascade of events in upgrading my solution to .netcore 3 and .net standard 2.. I will have to resort to manually running migrations on each release :*****(

Collapse
 
anskanth profile image
anskanth

Hey
Wondering if you have any solution/alternates for the problem I posted in here realted to deployment slots.. stackoverflow.com/questions/633845...

It's a bit bigger one but for sure an interesting one :)

Collapse
 
abmismi profile image
abmis-mi

Hi,
I want to add app insights logging to Azure Function v3 as we do in Web Jobs v3 like:
builder.ConfigureLogging((context, logging) =>
{
logging.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = appInsightsKey);
});

I tried similar code there but it didn't work.
builder.Services.AddLogging(builder => {
builder.AddApplicationInsights(appInsightsKey);
});

Is there a documented way of adding app insights to azure functions in code?

Collapse
 
dapoulin profile image
David Poulin • Edited

Hey,

Just a fast feedback on my experience with Azure Functions using net core 3.0
I was feeling quite lazy about installing another preview of visual studio 2019, so i kept using my current version (16.3.8).

My main prerequisite was to install the latest version of the azure function preview tools (i did it on powershell).

How i got using my azure function .net core 3.0 (with net standard library 2.1 ?).

1/ Creating azure function with vs 2019 (non preview)
2/ change in csproj AzureFunctionsVersion from v2 to v3
3/ update Microsoft.NET.Sdk.Functions to 1.0.30-beta2 (the 3.xxx does not work for me).
Each time i tried to debug with vs, i got a crash.
4/ Then, tried to start my project with command lines ( func start --build )
5/ Every thing goes well locally and when deployed to azure

On Azure portal, I only had to activate the runtime preview (v3). nothing else.

As you can not debug with my solution, you will have to use efficiently logging (everyone is supposed to do it right ;p).

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
 
eliashdezr profile image
Elias Hdez

Overall, dependency injection issues has been since the .NET Core 3.0 release. Can you follow up this please? @jeffhollan

github.com/Azure/azure-functions-d...

and this

github.com/Azure/azure-functions-d...

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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?