medilaser How to Run Background Jobs on Azure | Desuvit

Several applications run as background tasks that do not require user interaction. They run independently without needing assistance from the user interface. Background jobs start the interaction and keep taking interactive user requests. It minimizes the load that applications generally put on the user interface.

For instance, an application needs to generate thumbnails of the images that the user is uploading. You can do this as a background task where the upload gets done without waiting for it to complete. The user can upload the pictures, and they will automatically generate as thumbnails.

It is important to understand that not every application can run as background jobs. For an application to initiate background jobs, it should function without user interface assistance and user interaction.

  • Looking for Web development Partner ?

    A project in mind or an idea that you want to develop ?

    Contact us for a Free Consultation to talk about growing your business.

    Contact Us

Applications that need both these elements will not be suitable for background jobs. Some common types of background tasks are intensive processing tasks, long-running processes, and batch jobs.

In this article, we will learn about the process of running background jobs on Azure. Before we get into that, let us know more about background jobs and their process.

Variations of Background Jobs

You need to know the type of jobs that you can put under background jobs. Below is a list of several types of background jobs.

  • I/O Intensive Jobs: Indexing files series or storage transactions
  • Long-running Workflows: Provisioning systems and services, order fulfillment
  • CPU-Intensive Jobs: Structural model analysis, calculations
  • Batch Jobs: Scheduled processing, nightly updates of data
  • Sensitive-Data Processing: Send sensitive data to a secure background destination for processing

Background Jobs Triggers

There are two kinds of triggers when you initiate background jobs. They are event-driven triggers and schedule-driven triggers.

Event-driven triggers are those where the task starts to respond to an event. This event may be a step in the workflow or action initiated by the user. On the other hand, schedule-driven triggers are those where the tasks start at a particular schedule. That can be either through recurring schedules or by specific one-time schedules.

Processes to Run Background Jobs on Azure

There are multiple ways to run background jobs on Azure. Let us get an overview of the different Azure platform services that can host background jobs.

Background jobs on Azure

Azure Web Apps and WebJobs

WebJobs is a great platform that you can use to run custom jobs based on several executable programs or scripts. These scripts or programs will need to have the same context as web apps, API apps, and mobile apps.

  • Follow our tech founder for more valuable tips, tricks, learning, content and future opportunities

    Follow Here

Azure Functions

You can use this platform for background jobs that run for a short time. It is also usable if you have a workload that you are hosting on the App Service plan and the utilization is less.

Azure Virtual Machines

Users who have Windows service or wish to use Windows Task scheduler can run background jobs in a particular virtual machine.

Azure Batch

Azure Batch is a platform service that uses a collection of managed virtual machines to schedule compute-intensive background jobs.

Azure Kubernetes Service (AKS)

This service platform offers users a hosting environment for Kubernetes.

Now that we have an overview of the different platforms to run background services on Azure, let us look at each platform individually.

Azure Web Apps and WebJobs

Azure provides a feature called WebJobs that lets users run a script or program with the same context of a web app, API app, or mobile app.

There are several file types that WebJobs supports. Some of them are:

  • *.py (Python script)
  • *.sh (Bash script)
  • *.exe, *.bat, *.cmd (Windows executables)
  • *.js (Javascript)
  • *.php (PHP script)
  • *.ps1 (Windows PowerShell)

WebJobs uses the same App Service Plan that you use for hosting your web application. Due to this, there are no additional costs that the user needs to pay.

WebJobs Types

Users will come across two types of WebJobs that are continuous and triggered.

Once you have finished configuring, the continuous job will start. In case it ends in some way, you can start the job again. The code for a continuous job looks similar to an endless loop that is performing something. Remote debugging is also a part of this job.

Generally, continuous jobs run on all the web instances, but you can also select single instances.

On the other hand, triggered jobs will not work when you trigger them manually. They can also start running at the time you schedule them. Unlike continuous jobs, triggered jobs will run on a single instance. Moreover, you cannot remotely debug these jobs.


Depending on which type of job you want to create, there will be different configuration commands. For an event-driven trigger, the job has to be configured as “Run Continuously.” For scheduled-driven trigger responses, you can configure it with the “Run on a schedule” command.

The “Run on-demand” command will execute similar codes as the “Run on a schedule” option.

Azure Functions

Azure Functions works similar to WebJobs but does have a server. It is mostly used for event-driven triggers that do not run for a long time. You can select a function that would work scheduled jobs using different timer triggers. These triggers will be set at different times by the users.

Users should avoid running large and long-time tasks on Azure Functions since problems are related to unexpected timeouts. You can still use this service for schedule-driven triggers, depending on your hosting plan.

Hosting Models

Azure Functions come with two basic hosting models: the Consumption Plan and the App Service Plan.

The consumption plan offers the common functionality of Azure Functions. They are the pay-per-use feature and elastic scalability. Billing is based on the number of executions, execution time, and memory used. However, you cannot run a function for more than five minutes on this plan. If it runs more than five minutes, you will see an unexpected timeout that will end the function.

  • Your End-To-End Guide To Help You Plan And Build Web Applications

    Here’s the free guide to Answers to all your Web development Queries

    Download Free E -Guide

On the other hand, the App Service Plan lets the user choose the Virtual machine configuration. This plan is similar to the ones you get in WebJobs, where you have to pay for the dedicated VM even if you do not use it. You also need to manually enter the run-time if it goes beyond the VM scale.

The default option for hosting background jobs is with the consumption plan. It is best if you have multiple tasks for short time schedules but need to run continuously. However, you can change it to the other plan if required.

Azure Virtual Machines

Azure Virtual Machines is similar to other VM services, with the only difference being it is run on Azure. You can use clouds to run the virtual machines. The infrastructure provided by the platform is like a virtualized server that you can use for several services. Users can configure the software that is running on the virtual machine.

You can use virtual machines if you wish to take control of the operating system. It can also be chosen if you want to use customized hosting configurations or run any custom software. Creating a VM job is not a hard task; however, you need to be careful when selecting the image to create the VM. This image is a template that will have information about the OS and tools used for the job.

Scaling VMs

Azure Virtual Machines provides you with the choice to create as well as manage multiple load-balanced VMs simultaneously. The numbers for this can either decrease or increase based on your requirement or a schedule.

Using Azure VM for Background Jobs

If you want to host background jobs on Azure VMs, you get multiple benefits. You can get control over the scheduling, resource allocation, initiation, and execution of the jobs. It also offers immense flexibility and you can set the run-time of the jobs that you wish to deploy.

Azure Batch

Azure Batch is a perfect service if you wish to run high-performing computing (HPC) and other large-scale processes. Enterprises with large automated background jobs can use Azure Batch since they do not have a short timeout feature. They are capable of handling thousands of parallel jobs without facing abrupt job kills.

This platform performs parallel tasks such as data injection, software test case execution, image analysis processing, data process, etc. Azure Batch creates and manages a pool of compute nodes that are a large collection of virtual machines and installs the application on the compute nodes. After this, a schedule gets created for running the jobs on the nodes. You can manage, monitor, and configure the jobs with several Batch tools, commands, and API. Users can run both Windows and Linux VMS in Batch Service.

Configuration Process

The user can only use the Batch service if they have a Batch account. However, you can also use an Azure Storage account for the same. If you have an Azure Storage account, you need to input the application and files to process them.

You need to create compute nodes (VMs) to execute this process. This step requires you to configure other elements such as node sizes, OS, and others. Once the execution is done, create the job along with the associated tasks that you require. Azure Batch will automatically schedule the job in the compute nodes for execution when the job gets created.


When you use Azure Batch, you can choose the operating system to run the background tasks and parallel jobs. It is very easy to integrate the application to the Batch service and manage it. Moreover, users do not have to pay any extra charges for using the Batch service since it is pay-per-use.

Azure Kubernetes Service

Azure Kubernetes Service (AKS) is the platform that helps you manage the Kubernetes environment. This service platform makes it easy for the user to manage and deploy the containers of applications. Azure takes care of the hosted application containers through this platform service.

When using AKS, you can host and manage multiple containers needed for the applications. The functionality of AKS is similar to that of VMs, with some basic differences. The containers managed by Azure Kubernetes Service will run for a few seconds instead of several minutes as compared to VMs. A great thing about these containers is that they are quite lightweight. That leaves less scope for crashes or errors while running the job.

Azure Kubernetes Service is generally used for running long-background jobs. You will also need to have an idea about using a container orchestrator to use the Azure Kubernetes Service. It also depends on the skills of the DevOps team you are working with.

Container Usage for Solutions

It is quite beneficial to use the container for running background jobs. That is because you can host high-density applications using containers. The background task can be divided into containers. It is also quite beneficial to place multiple containers in Virtual Machines.

When you use containers for background jobs, the container orchestrator takes care of many functions. Some of these functions are internal network configuration, internal load balancing, etc.

You can also schedule the run-time of the containers as you want. When you use the Azure Kubernetes Service, you can register the containers in the Azure boundaries as stated by the Azure Container Registry. That gives you proximity benefits, security, and privacy.

Summing Up

Choosing the right platform service for running background jobs is necessary. Since Azure offers multiple choices, users might find it easy to make a choice. However, there are two main types of considerations that come into view when making a choice.

  • Call For Free Technical Expert’s Advice

Firstly, you need to determine the type of background job that you want to host. Secondly, the run-time of the job will decide the platform you can take. Different platforms offer different run times and configurations.

No matter which platform service you choose, it is essential to note that it should not kill the job. You cannot initiate a successful background job if it stops before its required or scheduled time. Choose a platform where the job will not crash and run its full duration.

If you are looking for a software development company, then let us at Desuvit help you with your project. Reach out to us today, and our team of experts will help devise a plan tailored for your specific business needs.

Desuvit is a Norway-born software development company delivering Custom Software Development, Mobile Apps, and Web Applications Development for various verticals and business domains. We offer end-to-end solutions for companies with no software or IT division, Startups, and companies that need to scale their software development efforts but lack the expertise required. We help our clients in growing their businesses so we can grow with them.

Some of the technologies we work with: .Net, Azure, Microservices, Azure functions(Serverless computing), React Native, Flutter, React JS, TypeScript, Angular, NServiceBus, Azure Service Bus, Azure Queues, SQL Service, MySQL, Cosmos DB, etc.

Contact Us Estimate Your Project

Enjoyed this article? Subscribe for more valuable and great content !

Enter your email address below to get new articles with valuable content delivered straight to your inbox, plus special subscriber-only content to help you with your next mobile app or software development project.

By subscribing, you agree with our privacy policy and our terms of service.