How to create a WebJob in Azure using Visual Studio

This blog post explains how to create a Webjob

Hi, the purpose of this blog post is to show developers how to create a WebJob. 
 

How to create a WEB JOB in AZURE?

 
Creation of Resource
 
1. Go to Azure Portal
 
2. Search for Resource group. Create a Resource group if you don’t have any
 
 
 
Creation of APP service
 
1. Search for APP service and create a app service
 
2. Give any name you want to the instance
 
 
 
Select the publish code, or if you need any docker, select Runtime stack (either core or asp.net frame work or tomcat ). Go to Monitoring tab if you want to enable Application insights. By default it will be enabled.
 
Click on Review + Create and click on Create.
 
Go to Azure portal -> Resource groups -> Resource (which you have created) -> webjob Appservice. Click on “Get Publish profile” and download and import it into Visual studio to publish the web job .
 
Storage Account
 
Go to Azure portal and search for Storage accounts and click on it.
 
Click on Add.
 
Click on Review +Create.
 
Go to Storage account, click on the Storage account previously created. Click on Access keys and copy the connection string.
 
 
 
Now go to Console APP
 
File->New->Project
 
 
 
Right click on solution -> click add -> New Item -> select JSON type and name it Settings.job
 
 
 
Open the “Settings.job” and add the following CRON expression:
 
{
"schedule": "0 0 */4 * * *"
}
 
Note: The basic format of the CRON expressions in Azure is:
 
{second} {minute} {hour} {day} {month} {day of the week}
 
Go to App.config and add the below line in the connectionstring tag
 
<add name="AzureWebJobsDashboard" connectionString= ”<connection string copied from storageaccount> " />
<add name="AzureWebJobsStorage" connectionString = ”<connection string copied from storageaccount>" />
 
 
 
 
Click on "Microsoft Azure App service" or Import the profile which we downloaded in the earlier steps.
 
 
 
 
Below, the screen should appear. Go to the settings tab, set configuration to “Release,” and publish.
 
Wait for the message below to appear in the output window of Visual Studio to assure that the deployment was successful.
 
Go to the Azure Portal on the below screen and click on WebJob. You should be able to find your WebJob here.
 
 
 
(It can be noted that you can run the WebJob on demand as well.)