Deploy a .NET Core web app and web job using Azure DevOps

Deploy a .NET Core web app and web job using Azure DevOps

A web job is very useful for running the background jobs required for applications. We already have seen what is a web job and how can we create it in AZ 203 certification blog series.

Recently, I was told to create a web application in .NET Core 3 and create a .NET core web job. I was told that it may be an interesting case to know more about web jobs as visual studio does not support adding a web job to .NET core web applications – YET.

So, this article explains my journey on how did I resolved this issue.

Web Job and .NET Framework

So, for experimentation, I created a sample web application in .NET framework using the .NET framework web application template provided in Visual Studio.

Next, I used Azure web job (.NET Framework) template to create a web job in the same solution. Then from documentation, I got to know that if you right click on the web project, then there is a menu option which allows you to associate the web app with the web job projects in the same solution.

This is really cool.

.NET Framework web application context menu

If you select the option highlighted in above snapshot, you will get a popup as shown below. The popup will ask :

  • Project name which should be added as Azure web job
  • Web Job Name
  • Web Job run mode, continuous or triggered ( i.e. Run on demand) type of web job.

I selected the details as shown below and clicked on OK.

Then I thought, let’s try to publish this to Azure and see if the web job gets deployed. I used Visual Studio Publish to publish the web application to Azure App service. After publish I could see the web job deployed properly.

When I opened the service editor in kudu, I found that web job is already deployed and it was working as expected. Nice !

So, if I want to replicate this in release pipeline, I just have to publish the web application to Azure. That same task will publish the web job as expected.

Web Job in .NET Core

Next thing, I created new solution which had a .NET Core 3 web application. Then in the same solution, I created a new .NET Core 3 console application which had below code in Main method. Refer one of my previous articles to know more details about this sample web job.

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MyFitnesLogRegisterUserJob
    class Program
        static void Main(string[] args)
            var builder = new HostBuilder();
            builder.ConfigureWebJobs(b =>
            builder.ConfigureLogging((loggingBuilder) =>

            var host = builder.Build();
            using (host)

When I tried to do all above steps in .NET core, I found that the “Add existing project as web job” option is not available for .NET core web application.

.NET Core web application context menu

So, I have a .NET core web application, a .NET core web job and a release pipeline that deploys the .NET core web application. But the web job is not getting deployed.

I understood that I will have to make additional modifications to my Release pipeline to deploy the .NET core web job.

Findings about internals of WebJob

So to understand what modifications are required to be done in the Release pipeline, I tried to open the .NET Framework sample web application in App Service Editor.

I found that the web job is deployed at path wwwroot/app_data/jobs/triggered/.

After some reasearch I found out that the last folder name depends on the type of web job. If it is triggered web job, then it is copied to triggered folder.

Alternatively if it would have been a continuous web job, it would have been present under wwwroot/app_data/jobs/continuous.

So, now I knew what I needed to change in my release pipeline.

Modifying the CI pipeline

I already had a CI pipeline setup done for my .NET Core web application. I just opened it, and added one additional step in it. I added a dotnet command task to CI and renamed it to Publish Web Job.

In that task, I selected command to be publish and I explicitly unchecked Publish Web Projects checkbox.

Then I specified path of the project explicitly in Path to project(s) input box. Also, I specified a arguments as shown below. It tells to publish the output of web job under the folder which is specified in –output clause.

Please note that I have used triggered folder in the path, because my web job was triggered web job. If you want your web job’s type to be continuous, then use “continuous” folder instead of “triggered“.

–configuration $(BuildConfiguration) –output $(build.artifactstagingdirectory)\App_Data\jobs\triggered\MyFitnessLogRegisterUserJob

Also, I unchecked the next two check-boxes as I did not want to ZIP the artifacts and I did not want to append anything in the output path.

Modify the release

I also had a release pipeline already setup for my web application. In that release, I made only one change. I changed the Package or Folder input.

Instead of specifying the ZIP file package which contains published web project, I specified the folder where both the app_data folder and ZIP package is available.

Testing the modifications

Then, I triggered a new build and waited until the application is deployed to Azure. And, the release deployed the web job as well under the Web App.

.NET Core Web Job Deployed on Azure

I hope you enjoyed this article. Let me know your thoughts.

Leave a Reply

This Post Has 7 Comments

  1. Alex

    Thank you! This was really helpful.

  2. Swetha

    Hi , have tried this .Webjob is deployed successfully but when it comes to deploying webapp i just see zip in wwwroot folder via kudus . Looks like zip isn’t deployed properly this way. When i point the path to .zip , then webapp deploys well. Can u help me if iam missing anything ?

    1. Manoj Choudhari

      It is very difficult to point out exact issue as I do not know the exact settings. I think you have checked Zip published artifacts checkbox. You can try exact steps in this article and compare settings with the snapshots provided here. That might help you to figure out the exact issue.

  3. Mukeem

    I have the same case but I need to do it using yaml file. I have two projects in one solution. One for webjob(I am using dotnet core worker service for it) and other one is my webapp. But I am not able to complete it using yaml.

    1. Manoj Choudhari

      I will try to cover YAML based deployment in next month. Stay tuned…

  4. Mukeem

    But the way have written is absolutely unique I come across over my google findings. Thanks