Deploying Azure WebJobs for Schedule Tasks
Aptify Azure Enablement comes with the ability to run the existing schedule tasks entity (configured in Aptify Smart Client) on Azure Portal as WebJobs.
This document provides the information on how to setup new web jobs and configure existing schedule tasks to run as Azure WebJobs. This topic is divided into three parts:
The current scope of the WebJobs is as follows:
Most of the existing schedule task functionalities are available in Azure Web jobs.
Only Once, Daily, Weekly, Monthly, Monthly Relative types of frequencies are supported.
The Scale of the job will always be “Single Instance” and Type “Continuous” on Azure Portal
Below points are not in the scope of WebJobs:
Run History Tab on Scheduled Task records will not be updated.
The functionality of the checkbox “Delete the task if it is not scheduled to run again” is not in scope for now.
Frequency types Run when computer is idle and Run when service starts is not supported.
Below screen shots are for reference purpose only. Please provide the details specific to your environment.
Part 1: Code File Config Changes
Extract the APTIFY_700_Database zipped file and go to the Core Database Setup->Utility->WebJobManualDeploy folder.
Search for WebJobManualDeploy.exe.config and open the same in Notepad or Notepad ++.
Configure the tags “AzureWebJobDashboard“ and “AzureWebJobStorage“ with your Azure tenant Storage Account Connection String.
Under the appSettings tag, the value for key=” frequency” will be any one of the following: all, once, daily, weekly, monthly, monthlyRelative. For example, a code with frequency daily will only run the task which are of type daily in database. It is to be noted that this setting is case sensitive.
Configuration Changes for Frequency TypeApp Insights has been configured for these web jobs and logs can be found in App Insight log file. To enable the app insights, Instrumentation Key is required (Line 25 of the picture below). Refer to Configuring Serilog with Azure Application Insights to know more about App Insight.
The below keys are required by web job to log into the database:
UserDatabase = “Aptify”
EntitiesDatabase = “Aptify“
SQLLogin and Password are the credentials to log into the database.
Server = Managed instance Endpoint (See Points 6.d.i to 6.d.iii)
To get managed instance endpoint, log in to the Azure portal and select SQL Managed Instances Service.
Select the instance to be connected with the WebJobs.
Once you select the instance you will find Networking under Security and Endpoint on the right pane of the screen as highlighted in below screenshot.
Once all the changes are done in config file, save and close it. Select all the code files and zip them, give the zipped file a meaningful name.
Part 2: Creating/Updating Schedule Task Record in Smart Client
Open Smart Client, collapse Process Pipeline Application and right click Scheduled Task Service, then click “New Scheduled Tasks Records“
Under the new scheduled task record, there are few mandatory settings which are needed to get this task run by Azure WebJobs. These are as follows:
Service: Alway select option “Schedule Web Job Only”
Web Job Enabled: This checkbox must be selected.
Is Enabled: This checkbox must also be selected.
Note: All other functionalities (Start Date, End Date, Repeat Task etc.) on “New Scheduled Tasks Record” remains the same. Also existing Scheduled Tasks can be modified to run by Azure Web Jobs. To do so, change the service to “Schedule Web Job Only“ and make sure the “Web Job Enabled” checkbox is selected.
Part 3: Deploying the zipped code file on Azure Portal
Open Microsoft Azure Portal, on the home page, click App Services.
Select the App Service through which your web job will run.
After selecting App Service, on the newly opened right pane, select “WebJobs“ under “Settings“
Under WebJobs, click + sign to add a new web job. A new pane Add WebJob opens on the right side of the screen. Under Name, give any meaningful name for the job.
Under File Upload, click upload button and a new window opens. Now select the zipped file created in Part 1.
Set the Scale to Single Instance.
Click OK, it may take few seconds for the job to be visible on the dashboard in Running Status. This will ensure that the scheduled tasks will start executing as per their schedule.