WebJobs - Overview

Job scheduling is a key feature in computing that we’ve grown to rely on for handling the execution of unattended background tasks.  When we originally launched Everleap the technology at the time prevented us from allowing batch processing.  A Windows Azure Pack update added a feature called WebJobs which allows a script or executable to run as a background task in your web application as part of your site.

 

Types

We support the ability to run an executable/script as a WebJob in the following context:
  • Continuous: A WebJob that will be always running
  • Triggered: A WebJob that is run on-demand when an API call is made or on when a scheduled condition is reached.

 

Requirements

In order to use WebJobs, you will need the following:
  • Everleap Reserved Cloud Server
  • The Always On setting must be enabled for your site

 

Supported File Types

We support the following file types:
  • *.bat
  • *.cmd
  • *.exe
  • *.js
  • *.php
  • *.ps1

 

File Locations

When a WebJob is created through the Everleap control panel, your executable/script along with any dependent files will be placed at:
  • Continuous: /site/wwwroot/App_Data/jobs/continuous/[JOB_NAME]
  • Triggered: /site/wwwroot/App_Data/jobs/triggered/[JOB_NAME]
IMPORTANT:
  • Any binaries located in a sub-directory of a WebJob folder will not be recognized. For example, files in the following path would not work: /site/wwwroot/App_Data/jobs/triggered/MyWebJob/SubDirectory.
  • If you're using FTP or Web Deploy to publish files to your site, make sure that you do not overwrite the App_Data directory.
When a WebJob executes, it is copied to: \TemporaryFolder\jobs\[JOB_TYPE]\[JOB_NAME]\UniqueRandomFolder and run from this location to prevent any file locks.

 

Usage

When a WebJob executes, the following conditions and logic apply:
  • A WebJob will initially look for run.cmd file
  • If a run.cmd file is not found, a job will look for another supported file type like run.exe or run.php.
  • File types are run determined by the following priority order: 
    • *.cmd
    • *.bat
    • *.exe
    • *.ps1
    • *.php
    • *.js
  • If a run.* file isn’t found, a WebJob will use the first supported file type that it finds.

 

Settings

Configuration Settings

  • WEBJOBS_RESTART_TIME: The timeout value in seconds between a continuous job stopping and re-executing.
  • WEBJOBS_IDLE_TIMEOUT: The timeout value in seconds when a triggered WebJob will spin down if idle.
  • WEBJOBS_HISTORY_SIZE: The number of entries that will be kept in a triggered WebJobs history – default value is 50.
  • WEBJOBS_STOPPED: Set the value of this setting to 1 to disable a WebJob. 

Environment Settings

  • WEBJOBS_PATH: The temporary path where the executed job is running.
  • WEBJOBS_NAME: Name of the WebJob.
  • WEBJOBS_TYPE: The type of WebJob – continuous or triggered.
  • WEBJOBS_DATA_PATH: The metadata path for the WebJob that will contain logs, history, etc.
  • WEBJOBS_RUN_ID: The run ID of the triggered job.

 

settings.job File

You can deploy a settings.job file with your binaries that will allow you to manipulate the settings of a WebJob.
Global settings
  • is_in_place: The setting allows a WebJob to run in-place from the default WebJob path. The parameter accepts boolean values of true and false.
  • stopping_wait_time: Controls the behavior of the WebJob if a site recycles. Number in seconds.
Continuous
  • is_singleton: The setting will run a WebJob on a single instance. The setting will take true/false values.
Triggered
  • schedule: Set the frequency at which the triggered WebJob will run with a CRON schedule. 

 

Logging

For continuous WebJobs, Console.Error and Console.Out are written to the application log and the first 100 lines of output will be written to the WebJob log that can be accessed through the Everleap control panel.

For triggered WebJobs, Console.Error and Console.Out are written to the log file for the specific task that was run.

NOTE: Console.Error is recorded as an ERROR and Console.Out is marked as INFO in the Windows Logs.

 

Further Information