OverviewWeb Jobs is a feature of Azure App Services that run runs a program or script in the same instance as a web app, API app, or mobile app. There is no additional cost to use Web Jobs.
...
Table of Contents | ||||||||
---|---|---|---|---|---|---|---|---|
|
The Current current scope of the WebJobs is as follows:
Only Once, Daily, Weekly, Monthly, Monthly Relative types of frequency frequencies are supported.
Run History Tab on Scheduled Task records will not be updated.
Service should always be “Schedule Web Job Only“ on Scheduled Task record to run the task as WebJob.
The functionality of the checkbox “Delete the task if it is not scheduled to run again“ is not in scope for now.
The Scale of the job will always be “Single Instance“ and Type “Continuous“ on Azure Portal, more is discussed in the document below:
Part 1: Code File Config Changes
Open the Zipped Folder Containing the code files. <<path and name of the file>>
Search for WebJobManualDeploy.exe.config and open the same in Note Pad Notepad or Note Pad Notepad ++.
The Configure the tags “AzureWebJobDashboard“ and “AzureWebJobStorage“ both are to be configured with Storage Account Connection String.
Under the AppSettings appSettings tag, the value for key=”frequency” ” frequency” will be any one of the following: all, once, daily, weekly, monthly, monthlyRelative. This is for the type of job which is needed to be scheduled on portal. 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.
App Insights has been configured for these web jobs and logs can be found in App Insight log file. But to 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 log files.
To get the instrumentation key for App Insights, log into in to Azure portal and select the service Application Insights.
Select the Application Insights for which you want to configure the logs.
Under the overview tab you will find the Instrumentation key.
The below keys are required by web job to log into the database:
UserDatabase = “Aptify”
EntitiesDatabase = “Aptify“
SqlLogin SQLLogin and Password are the credentials to log into the database.
Server = Managed instance Endpoint (See Point 10-12)
To get managed instance endpoint, log into in to the Azure portal and select Sql SQL Managed Instances Service.
Select the instance to be connected with the web jobs.
Once you select the instance you will find Networking under Security and Endpoint on the right pane of the screen as shown highlighted in below screenshot below.
Once all the changes are done in config file, save and close it. Now Select all the code files and zip them, give the zipped file a meaning full name. After this we are done with the code file changesmeaningful name.
Part 2: Creating/Updating Schedule Task Record in Smart Client
Open Smart Client, Collapse collapse Process Pipeline Application and right click Scheduled Task Service, then click “New “New Scheduled Tasks Records“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 (Once you select service as Schedule Web Job Only, this will be automatically selected).
Is Enabled: This checkbox should must also be selected.
...
Info |
---|
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 JobJobs. To do thatso, just change the Service service to “Schedule Web Job Only“ and make sure the “Web Job Enabled” Checkbox 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 in 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 part 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 under on the dashboard in Running Status. Now it This will ensure that the scheduled tasks will start executing the scheduled task as per their schedule.