Step By Step Procedure To Deploy Azure Web Job

Azure Web Job

 
At its most basic, Azure Web Job is a service which comes with Azure websites and it can be invoked by a trigger or run continuously. To understand it easily, we can say that Azure web job is a specialized scheduler with specialized features.
 

Deployment Procedure

 
To deploy an Azure web job, we can go with manual deployment using the Azure portal or deployment using Visual Studio. Either way, we need an Azure App Service to deploy the web job. In this article, we will discuss the manual deployment procedure. So, here are the pre-requisites to deploy the Azure web job.

Let’s say we have a console app ready to deploy in Azure as Web job. To know about details about Azure Web job Development you can check my previous article: How To Create An Azure WebJob For SharePoint Online. Specifically, for SharePoint, if the application is developed with User Authentication, then there is no need to create a client app in the SharePoint Site. But if the application is created with SharePoint App authentication (client id and client secret), then we need to create a client app and provide proper permission which is already covered in my previous article.
 

Create an Azure App Service

 
To deploy an Azure Web Job for both the procedures – Manual Deployment and Deployment using Visual Studio --  we need an Azure App Service. Here is the detailed procedure to create an Azure App Service.
  1. Login to your Azure panel through the following link: https://portal.azure.com
  2. First, select App Services from the left navigation bar, then click on the add button as shown in the photo below.

    Step By Step Procedure To Deploy Azure Web Job
  1.  After clicking the Add button, the below window will open.
  2. Click on Web App as shown in the below picture’s position 1. Then the Web App window will open on the right side, where we will find the create button as shown in the picture’s position 2. Click on the Create button.

    Step By Step Procedure To Deploy Azure Web Job
  1. The below window “Web App Create” will pop up or open on the right side.

    Step By Step Procedure To Deploy Azure Web Job
  1. Provide the App Service name in position 1 which needs to be unique, which means there can’t be any app service with the exact same name. 
  2. Select a Subscription from the drop-down of position 2. This is to use the subscription methods which you already registered for.
  3. Select an existing Resource Group or create a new one. These resource groups are being created under Subscriptions. And the App Service which we are creating will be under the Resource Group which will make it easy to impose any rules upon a large number of the same App Services.
  4. Select preferred Operating system -Windows or Linux. As we are working with Windows, have selected Windows here from position 4.
  5. In position 5, unless you are using Docker, select code as selected here.
  6. Select the preferred App Service Plane from position 6. This App Service Plan manages the application server location on which region the app will run and the pricing plan. 
  7. Now, in position 7, we have the Application Insights mode. This is Log Analytics which is selected as “Off” by default. But if you need to trace the log, you can make it “On”.
  8. After completing all the necessary things, click in the “Create” button.
  9. It will take a few moments to create the App Service and we will open the “Application Service” overview window. And this app service is ready to be deployed on the Azure Web Job.

Deploy the Azure Web Job

 
As we are saying we have already developed the web job (Details Development Procedure), now we can deploy the web job on this newly-created web app. The procedure is described here step by step with related figures:
  1.  Now open the web job solution in your Visual Studio.

    Step By Step Procedure To Deploy Azure Web Job
  1. Select “Solution Configurations” as “Release” and Build the project from solution explorer of Visual Studio as shown in the above picture.
  2. Now in the “bin\Release” folder, we will get the compiled files. Address of the release folder: “<Solution Folder>\<Project Folder>\bin\Release”.

    Step By Step Procedure To Deploy Azure Web Job
  1. Select all the files and zip them. 
  2. Now, again go to the Azure portal and open the app service which we just created.

    Step By Step Procedure To Deploy Azure Web Job
  1. Select Application settings as shown in position 1 and insert the “ClientId” and “ClientSecret” here as shown in position 2.
  2. Provide “ClientId” string in the key portion and provide “b4f974fb-63ff-40d0-b5ba-4d323fcad9bf” in the value. And do the same for the client secret. Then, Save.

    Step By Step Procedure To Deploy Azure Web Job
  1. Now select WebJobs from left navigation as shown in position 1 and click Add at position 2. A new window will open on the right side of the screen.

    Step By Step Procedure To Deploy Azure Web Job
  1. Provide the web-job name in position 1 as we have provided “TestWebJob”.
  2. In position 2, upload the zip file which we have built on step 4. 
  3. In position 3, we need to provide the running method of this web job. There are two types of running method – “Continuous” and “Triggered”. Continuous web job starts immediately when the WebJob is created and runs on all instances that the web app runs on. Triggered web job starts only when it gets triggered manually or on a schedule and it runs on a single instance that Azure selects for load balancing. So, for this article, I have selected Triggered.
  4. In position 4, we need to select the “Triggers” option – Scheduled or Manual. For Manual, the web job has to be triggered manually or by an API. And for Triggered option, there will be a schedule of which web job will run. So here we have selected the Scheduled option and as a result, the “CRON Expression” field will be visible.
  5. So, in this potion 6, we need to provide the CORN expression to declare the schedule. This CRON expression is composed of the following six fields -> {second} {minute} {hour} {day} {month} {day of the week}. As we wanted to schedule the web job for 9 a.m., we have written the CRON expression as follows: "schedule": "0 0 9 * * *". For more examples and details about the CRON expression, the following Microsoft documentation, “CRON Expression” has good enough information. 
  6. Now, click the OK button in position 6 which will deploy the web job.

    Step By Step Procedure To Deploy Azure Web Job
  1. After successful deployment, the web job will show on the panel as shown in the above image with details. 
  2. So, we can run the web job manually to test that there is no run time issue/error from potion 1.
  3. After the web job got completed we can check the log from position 2.

    Step By Step Procedure To Deploy Azure Web Job
  1. Clicking the “Logs” button in Position 2 will open a new tab as shown in the above.
  2. We have the log “Web job ran successfully” which indicates the Web job ran without getting any error.

Conclusion

We discussed the Azure web job,  which is a remote SharePoint timer job, and we have talked about SharePoint and SharePoint related topics in this article. Deploying the web job in Azure is pretty much the same wherever the job will act. I hope this article will help people who are new to Azure web job. If anyone has any suggestions to update the article, please provide your feedback.


Similar Articles