How To Execute a Scheduled Job In Azure Portal

Introduction

This article will help you to understand and also guide you at each step to deploy the scheduled job; the executable is in the Microsoft Azure portal.

In the normal Web Server, we used to have the Server box in control and this was used to deploy all our executable files and also schedule the jobs for a particular time, using the Windows task scheduler.

When it comes to the Azure environment, there should be some option for the execution on this scheduler, which is explained below: 

Task Scheduler

This is the one we use to schedule our jobs in the Web Server. People have some doubts about the task scheduler. Here, we can clear up these doubts and then continue with the Azure equivalent one.

Normally, in some of the Web Applications, there will be some set of operations required to be performed on some time limit, say for example:

Send the report mail every week on Friday evening at 5 pm.

Group the data and generate the report on every last day of the month and store it in some location.

Update the database with the log in information of the Application.

These tasks can be done manually. To avoid some human interventions, the small Application will be created and the executable files will be deployed with the time to be executed, using this task schedule and based on the time, the activity is achieved on time without any interruptions.

interruptions

Azure Environment

In Microsoft Azure, we don’t have full control of the Server box, as we can access the normal dedicated Server to host our Web Application, so Microsoft has provided the option for scheduling such timely tasks, using the option in the Azure portal called “Web Jobs”.

Web Jobs

Web Jobs are the option equivalent to that of the task scheduler in Windows environment for executing all the background operations in the Azure portal.

All the executable files that need to be executed in the background can be deployed to Azure, using the Web Jobs.

What are all the files can be deployed in Web Jobs?

The Web Jobs has a provision to execute many sets of files, not limited to that for .exe alone. Following are the sets of the files, that can be executed in the back ground, using the Web Jobs portal.

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

Web Jobs in Azure Portal

Log on to the Azure portal with the following URL, where you have an access to the Web Application hosted and also require the executable to be scheduled.

Login with your Microsoft account credentials.

Select the App Services options in the menu available in Azure portal.

App Services

The “App Services” is the place, where the Web Application is deployed and hosted in Azure Services.

If you have any scheduler that has to be related to the Web Application, it can select the “Web Jobs” of that particular app Service.

Web Jobs

Select the particular app service, click on the settings and you will get the option to see the Web Jobs portal.

In the settings panel, scroll down and find the “Web Jobs” options.

settings

Add Web Job

There will be the option to Add Web Jobs. If you wish to edit any of the Web Jobs, you can click on the any of the Web Jobs, which are already available and all the available jobs will be displayed in the grid panel in the Web Jobs option board.

Add Web Job

In the Add Web Job, we can find some options and their details are given below.

  • Name
  • File Upload
  • Type
  • Scale

Name

This is the name for the Web Jobs. The unique, meaningful and valid names will be shown with the “green light” image in the name text box.

Name

File upload

This is the option to upload your files. You can either upload executable files or various sets of files like executable files with configurations and any other related files -- all those can be added to a folder and zipped and then uploaded to the Azure.

Note: Only the .Zip files can be uploaded to the web jobs.

Type of Job

This option is used to select the job execution. You can execute it continuously or based on some time or event based triggers.

Say for example, some Application has to copy the data from the file, whenever the user uploads a file, which is a continuous process. If the report has to be mailed daily at 5 PM, it can be a triggered process, based on time.

Type of Job

Trigger Options

As we discussed, triggered options need some time of execution and this trigger will have the option to specify the time values of an execution.

Trigger Options

The values of time to be triggered are defined by using the “CRON” expression.

CRON Expression

NCrontab is a NuGet package, in which the CRON Expression is implemented.

CRON expression has 6 fields

  • {second}
  • {minute}
  • {hour}
  • {day}
  • {month}
  • {day of the week}

In the following order:

  • {second} {minute} {hour} {day} {month} {day of the week}

Special operators are also supported,

  • , - * /

Each value represents a point in time, say for a sample trigger event:

"8 * * * * *" - means on the 8th second of every minutes as 00:00:00, 00:01:08, 00:02:08,

Samples

0 0 14 * * * - 2PM of the day [Daily Task].
0 30 10 * * * - 10:30 AM every day.

Scale

This is to state  how many instances the jobs have to be executed as “Single” or “Multi”, based on the user requirement. This can be selected.

Scale

Save the web jobs Options

On a click, the Web Jobs will be saved and will be executed on the triggered time.

 Save the web jobs Options

Manual Execution of Web Jobs

Yes, manually you can execute any Web Jobs in Azure portal.

In the Web Jobs portal, select any of the jobs and click on the “Run” option, so the jobs are executed and also the status will be displayed as “Running” or “Completed” with the duration details.

Other information can also be retrieved from the log option available.

Manual Execution of Web Jobs

Conclusion

Hope this article provided a clear view on Web Jobs in Azure portal.

Up Next
    Ebook Download
    View all
    Learn
    View all