Create your first Azure Web job (.Net Framework)

Sachin Hegadepatil
ashsoftware
Published in
4 min readOct 7, 2019
Image source https://koukia.ca

In the modern world, the IT industry is moving to the cloud platform for better performance and scalability. Azure is one of the platforms to provide such services. In this article, we will learn about how to create a web job and deploy it on the Azure portal.

Content

Why we need web jobs?

How we create our first web job?

Web job is a feature of app service used to do some small work by running it in the same app service or context. There are many reasons to create web jobs but nowadays people seem it as an automated task.

Prerequisites

  1. Visual Studio
  2. Azure Subscription
  3. Azure App service
  4. Azure Cloud SDK
  5. Basic C# knowledge

Why we need web jobs?

For understanding the need let's take the real-world example. Suppose there is a website for booking the villa online (Let's call it www.bookmyvilla.com). Every day hundreds of people go there and book their liked villa for vacation. There are 70 people who complete the booking and 30 people left the booking in the middle. For those 30 people, the marketing team needs to send the mail to the next day with more exciting offers and the best prices for booking villas. Every day they need to do the same job.

To get rid of the monotonous boring job, www.bookmyvilla.com decided to use some automation to do this job. Webjob can help us here in automating this work.

This web job will run every morning and will pick up the booking which was left in the middle and send customers the offers. This will save lots of people time and work. (Hope you understood the small example for why we need the web job).

Now let's move to some real work.

How to create the web job?

There is a feature provided by Visual studio in Cloud to create the azure web job.

From the image, you can select the azure web job as a new project.

When you select the azure webjob you will get the following screen -

Now it looks familiar for writing some code :)

Here I have added the code which displays “i” counter value through the loop. You can write your task here which maybe your database call, API call or anything.

Once you are done with your code then you right-click on the project and select the “Publish to Azure Web jobs” option.

Then you have to select the Azure app service for the deployment.

Once you select the azure app service then select the ok button.

Then the following window will appear and please check you have selected the right app service and check the destination URL. Then you have to click on the Next button.

Once the following window appears then select the publish button.

Once your publishing is done then you can go to azure app service and select the web job, there you can see your published web job with your project name.

Summary

In this article, we learned about how to create a web job using the Azure web job. To see the deployed web jobs on the azure portal, use the following link.

https://medium.com/@sachinhegadepatil09.sh/create-a-web-job-using-the-console-application-net-framework-and-deploy-on-azure-app-service-410c32615404

--

--