5

I created a WebJobs app targeting .NET Core following this article: http://matt-roberts.me/azure-webjobs-in-net-core-2-with-di-and-configuration/

I had to do this manually because currently Visual Studio does not provide a way to create a WebJobs app in .NET Core but I can create a console app targeting .NET Core in Visual Studio 2017.

Now, I want to publish my WebJobs console app to Azure but I'm NOT getting the option to Publish as Azure WebJob which Visual Studio typically gives -- see below: enter image description here

Instead, I'm just getting "Publish" option and not sure if this will work as intended.

How do I publish my manually created WebJobs console app to Azure as a WebJob?

Sam
  • 26,817
  • 58
  • 206
  • 383

1 Answers1

3

You can always publish WebJobs manually. There are several ways:

  • Directly copy the relevant files into d:\home\site\wwwroot\app_data\jobs\continuous\{job name} (e.g. using Kudu Console)
  • Zip up all the files and upload it as a continuous WebJob using the Azure Portal

Also, for the WebJobs engine to know how to run your Core app, you will need to include a run.cmd file that runs it (place that file in the same folder). e.g. it should contain something like dotnet YouWebJobAssembly.dll, or whatever command line you want to use to start it.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • I assume I need to zip up files in `\bin\Release\netcoreapp2.0` folder, correct? Also, only the `DLL` files or `json` files too? I see `myapp.deps.json`, `myapp.runtimeconfig.json` files as well. – Sam Dec 30 '17 at 20:32
  • 1
    You need to include whatever makes up your app. e.g. if you were to run this app locally from some random folder, you'd have a set of files. That same set is what you need. The WebJobs engine has no specific knowledge of your app layout. It will just run the executable and it will do what it does. – David Ebbo Dec 30 '17 at 20:35
  • I also just added info about including a `run.cmd`. – David Ebbo Dec 30 '17 at 20:43
  • I'm confused. I'm now getting an error that states that An assembly specified in the application dependencies manifest (MyApp.deps.json) was not found: package: 'Microsoft.AspNetCore.Http.Abstractions', version: '1.1.0'. Looks like this approach is not handling the assemblies that are installed with NuGet packages. I don't see any of them in the `bin` folder though. – Sam Dec 31 '17 at 00:43
  • Try to isolate by running it directly from Kudu console. This way it's no longer a WebJobs issue – David Ebbo Dec 31 '17 at 00:47
  • Looks like .NET Core 2.0 app may not copy assemblies that the app depends on. I added `true` to `csproj` file which actually worked and copied all the necessary assemblies BUT now I'm getting an error on WebJobs console telling me that package: 'System.Data.SqlClient', version: '4.4.2' was not found. The `SqlClient.dll` is there but if I right click the file and check version, it's showig 4.6. I don't know why Visual Studio would copy the wrong version of this `DLL`. In `csproj` file, the version number is the correct one. Frustrating! – Sam Dec 31 '17 at 01:18
  • That's sounds like a separate question about how to build your app in general, and not related to WebJobs in particular. I suggest a new question to tackle this. – David Ebbo Dec 31 '17 at 01:59
  • I see you posted on https://stackoverflow.com/questions/48040013/net-core-2-console-app-dependencies-issue-on-azure and got that part resolved! – David Ebbo Jan 01 '18 at 03:47
  • 1
    Yes, thanks. Made me remember how much I appreciate UI based solutions. Sometimes getting into the nitty gritty is fun. Other times it's like seeing the guy take off the Goofy costume at Disney! It can scar you for life :-) – Sam Jan 01 '18 at 06:10
  • @Sam interesting analogy :) – David Ebbo Jan 01 '18 at 18:22