Search code examples
c#asp.net-corevisual-studio-2019azure-webjobsazure-webjobssdk

Visual Studio 2019 - Adding WebJob project in WebApp


In my solution i have an aspnet core 2.2 WebApp, and i want to add an existent project like webJob but there isn't the option: Add WebJobs from existent project

enter image description here

Why? With the same procedure i add WebJobs on my other .Net application, and this option is shown in visual studio 2019

EDIT

Changed images with english language. Sometimes the Add > Existing project as Azure WebJobs it's showned but if I click on it it shows this error:

enter image description here

(the selected project is the aspnet.core 2.2. WebApp)

After this click , the Add > Existing project as Azure WebJobs is no longer visible.


Solution

  • Update:

    For example, if you want to deploy a console app as webjob manually.

    1. Create a Console app. Below is my code:

      using System;

      namespace testwebjob { class Program { static void Main(string[] args) { Console.WriteLine("This is my first webjob!"); } } }

    2.Build the console app, then right click and choose this:

    enter image description here

    3.Go to bin -> Debug -> xxx, then you will find a folder with below files,add a run.cmd and zip them.

    enter image description here

    This is the content of my run.cmd:

    @echo off
    
    dotnet testwebjob.dll
    

    enter image description here

    4.Go to azure web app, search webjob. Click add and upload the zip file.

    enter image description here

    enter image description here

    5.Then the web job has be deployed. This is the log:

    enter image description here

    Original Answer:

    From the documentation, you will find that 'Enable automatic WebJobs deployment with a web project' is a feature supported by .net framework web app. It seems .net core web app is not supported.

    In fact there is already a feedback about this. You can vote here:

    https://developercommunity.visualstudio.com/content/problem/806009/existing-project-as-azure-webjob-results-in-generi.html

    Maybe you can try not to use this feature and choose to deploy the web job after the web app is deployed.:)