Tech Blogs

perspectives for IT decision makers

Introducing Azure WebJobs

by (January 5, 2017)

WebJobs

Microsoft Azure is the Cloud computing platform and infrastructure created by Microsoft. Azure is known for building, deploying, and managing applications and services through a global network of Microsoft-managed data centers. WebJobs in Microsoft Azure is considered to be a feature of Azure App Service. It lets you run a program or script in the same context as a web app, API app or mobile app. Azure WebJobs is a feature provided by the cloud computing platform of Microsoft which enables you to run programs/scripts as background processes by a part of Azure websites.

Supported Files

The scripts or programs could be written in any of the following file types:

  • .cmd, .bat, .exe (using windows cmd)
  • .ps1 (using powershell)
  • .sh (using bash)
  • .php (using php)
  • .py (using python)
  • .js (using node)
  • .jar (using java)

Creating and deploying a Sample WebJob in Azure

Let us explore the creation and deployment of a sample WebJob in Azure. We will create a sample console application for the demonstration. This will be a “HelloWorld” Azure WebJob.

Here’s the snapshot of the console application solution:

WebJobs

And the Program.cs

WebJobs Script

Now, let us try deploying this WebJob to Azure.

Right click the solution and choose the “Publish as Azure WebJob” option:

Programs in Azure WebJobs

This will take you to the following screen:

MS Azure WebJobs

We can provide the settings for the WebJob, here. This includes the WebJob name and the run mode.

We have provided the WebJob a name and that is “HelloWorld”. We, now have three options to choose the run mode.

This includes:

  • Run on Demand
  • Run Continuously
  • Run on Schedule

The run mode needs to be determined based on the WebJob’s specific requirement. Some WebJobs need to be run all the time. This could be configured as “Run Continuously”. Some WebJobs need to be run only when the user desires to trigger them and this could be configured as “Run on Demand”. Some WebJobs might need to run on specific intervals or a schedule and is configured as “Run on a Schedule”.

For the demonstration, let us choose the option “Run on Demand”.

Once this is chosen, click “Ok” button to proceed.

In the next screen, choose the Azure App service to which your WebJob needs to be deployed:

WebJobs Deployment

Once the App service is selected, click on the “Publish” option to get the WebJob published in Azure.

Monitor the Azure App Service Activity window in Visual Studio to track the WebJob that is published. Once the publishing is successful, login to the respective azure account and choose the App service.

Choose the “WebJobs” option from the selected App service:

Setting up WebJobs

The “HelloWorld” WebJob will be listed as follows:

Introducing WebJobs

Select the “Run” option from the top to execute the WebJob

WebJobs running scripts

After the WebJob is executed, the status will be changed to:

Hello World in Azure WebJobs

To see the logs of the WebJob execution, click the “Logs” option from the top. This will navigate to a new tab with the log information of the respective WebJob as follows:

WebJobs Run

And with this, we have completed the creation, deployment and running our first WebJob in Azure!

Conclusion

Azure WebJobs are known to provide a way to run background tasks either continuously or on schedule. The WebJobs run on the same virtual machine that your web app is running on. They support a variety of file formats like exe, cmd, bat, sh, php, py and js. WebJobs can be deployed together with your web application and you are able to manage, view and trigger all jobs through Azure portal.

By,

Bisileesh P.B

Sr. Software Engineer, RapidValue

Sorry no comment yet.

LEAVE A COMMENT

24/7 Toll Free(877)-643-1850(US)

Would you like to know more about us?

  • This field is for validation purposes and should be left unchanged.
Scroll Top