1
votes

I've got 2 projects which are all .NET core. An infrastructure project which defines the schema, models, commands, queries etc. and an API which consists of endpoints/controllers to work on the data. The entire setup resides on Azure with the database being an Azure SQL.

The system is for analytics, so the entire setup is based around Read Only API's and what not. However, I obviously need to insert data into the database. The data comes from software out of my environment, so my idea was to create a WebJob which would receive the payload on an Azure Queue, use NewtonSoft JSON to populate my models and insert it into the database.

If I created a normal Azure WebJob it would use a .NET version which was not compatible with .NET Core, so I instead setup my project as here. In order to set my web job up, i needed to configure it:

    public static void Main(string[] args)
    {
        var config = new JobHostConfiguration
        {
            DashboardConnectionString = "",
            StorageConnectionString = ""
        };

        var host = new JobHost(config);
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }

In order to use RunAndBlock(); as well as the configuration I need to reference mscorlib, which I do in my project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.Azure.WebJobs": "1.1.2",
    "Microsoft.Azure.WebJobs.Core": "1.1.2",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.3"
    },
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "Microsoft.WindowsAzure.ConfigurationManager": "3.2.3",
    "WindowsAzure.Storage": "8.0.1"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dnxcore50",
        "net451"
      ]
    }
  },

  "publishOptions": {
    "include": [
      "run.cmd"
    ]
  },

  "runtimes": {
    "win10-x64": {}
  }
}

Reading here regarding the "Microsoft.NETCore.Portable.Compatibility" package, it says:

As such, when using this package you may encounter errors like

error CS0012: The type 'WebRequest' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Requests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Which is exactly what I get,

Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The located assembly's manifest definition does not match the assembly reference.

I am, however, not entirely sure how to fix this. My dependency foo is not super strong, and I'm not sure if I'm even able to get Azure Queue storage + webjobs to play nicely with .NET core

So how do I fix it, if it is fixable?

2

2 Answers

1
votes

According to your scenario, I tried to build the NETCore console application for my WebJob and I could encounter the same error as you provided. Then I found some similar issue and issue about WebJob SDK in NETCore, and as David Ebbo stated as follows:

To clarify, Azure WebJobs that use .NET Core work fine. It's specifically the use of the WebJobs SDK that is not yet supported.

Considering your scenario, I assumed that you need to build normal WebJobs and the related library (models,queries,etc.) instead of NETCore, in order to use WebJobs SDK. Or you need to re-design your scenario.

0
votes

In case somebody is still looking for a solution, this is supported in the recent version

Install-Package Microsoft.Azure.WebJobs -Version 3.0.0-beta4

Please note that this package is still in beta. You can check for the latest updates at https://www.nuget.org/packages/Microsoft.Azure.WebJobs/3.0.0-beta4