Azure function with .net core 2 class library

4.2k Views Asked by At

Since there is still no support for Webjobs in ASP.Net Core, i am going to use Azure functions instead.

I have 2 class libraries that are build with on .net core 2. i can reference them to my Azure function project without any issue but when i try to publish i get this error.

Error

This is the reference from the Azure function to my lib enter image description here

Any idea on how i can make this work? without changing my class lib?

3

There are 3 best solutions below

1
On BEST ANSWER

Azure Functions doesn't currently support .Net Core 2 (more specifically, .Net Standard 2), however, it seems like the team is actively working on getting this support out...see here: Port runtime to .NET Core

Runtime will be ported to target Netstandard 2.0.

Depending on the functionality of your libraries, you may see if its possible to target instead Netstandard 1.3 which they do currently support

This issue will track the .NET Core port activities for porting the runtime to .NET core. Note that netstandard 1.3 assemblies can be used on Azure Functions and this is fully supported.

Update: added clarity based on @derape comments

0
On

Since there is still no support for Webjobs in ASP.Net Core

My understanding is that the VS tooling is not ready yet, so you cannot have a project template targeted at that, or some easy Publish as webjobs menu item.

But as far as I got reading through blog posts, you can create a .NET Core console application, add some .cmd file to project root with content like:

REM run.cms - Webjob entry point
@echo off
dotnet MyNetCoreConsoleApplication.dll

include that in the set of published files (with project.json "publishOptions": { "include": [...] } and finally make the webjob point to that cmd script. See for example here, or search for azure webjobs dotnet core.

1
On