This SharePoint online tutorial explain how we can create Microsoft Azure webjobs for SharePoint online using Visual Studio 2015 and then how to deploy web jobs to Microsoft Azure. For SharePoint onpremise environment we have timer jobs, by which we can do scheduled tasks in SharePoint farm. But in SharePoint Online environments we can not deploy any farm solutions but timer jobs can be created using farm solutions. But we can do scheduled tasks in SharePoint online (Download PDF for FREE) Office 365 by using Azure WebJob. Azure WebJobs are timer jobs for SharePoint online environments.
Here we will discuss how we can create Azure webjobs using visual studio 2015 using SharePoint online environment and then we will discuss how we can deploy web jobs to Microsoft Azure. Follow below steps:
SharePoint 2016 Tutorial Contents
Open Visual Studio 2015 and then click on File -> New -> Project. And then in the New Project dialog box, select a Console Application from Visual C# -> Windows category like below:
Now click on Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution… like below:
Now in the Manage Packages for Solution, click on Browse tab and search for “App for SharePoint” and click on AppForSharePointWebToolkit. And then select the Project and click on Install like below:
In the Preview changes page click on OK like below:
Once the installation done successfully. The solution will look like below:
Now in the app.config file, we will maintain the user account and password which will be used for comuunicating with SharePoint Online.
<?xml version=”1.0″ encoding=”utf-8″ ?>
<supportedRuntime version=”v4.0″ sku=”.NETFramework,Version=v4.5.2″ />
<add key=”SPOAccount” value=”******@onlysharepoint2013.onmicrosoft.com” />
<add key=”SPOPassword” value=”**********” />
The app.config file looks like below:
Now in the Program.cs page we will write the code which will add an item to a SharePoint online list. The code looks like below:
static void Main(string args)
using (ClientContext context = new ClientContext(“https://onlysharepoint2013.sharepoint.com/sites/Bhawana/”))
context.AuthenticationMode = ClientAuthenticationMode.Default;
context.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
var list = context.Web.Lists.GetByTitle(“MyDemoWebjobsList”);
ListItemCreationInformation newItemCreateInfo = new ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem newItem = list.AddItem(newItemCreateInfo);
newItem[“Title”] = “Item added by Azure WebJobs”;
private static SecureString GetSPOSecureStringPassword()
var secureString = new SecureString();
foreach (char c in ConfigurationManager.AppSettings[“SPOPassword”])
private static string GetSPOAccountName()
Deploy WebJobs to Microsoft Azure:
Now we will deploy the WebJobs to Microsoft Azure. Before procedeing further we need to create a web apps in Microsoft Azure and we need to get the Publish Profile for the web app. Follow the below articles and get the pulish profile which we will need later.
Now right click on the Project and click on “Publish as Azure WebJob…” like below:
In the next screen in the Add Azure WebJob, You can provide the WebJob name and also you can schedule the job according to your requirment like below. Here we have just set the run mode as “Run Continuously” like below:
Now in the Publish Web dialog box, click on Import like below:
Then browse to the profile which we have imported through the above url like below:
Then it will populate all the details like below. You can also click on Validate Connection button to validate the connection like below.
Once it will published successfully, if we will open the list, we can see few items has been added like below:
We can also review the WebJob in Microsoft Azure Portal. Login to Microsoft Azure Portal and select the Web App and then select WebJobs and then you can see WebJob running like below:
Read some sharepoint online tutorials:
- Steps to create a provider hosted add-in in SharePoint Online
- CRUD Operations with ECMA or jsom in SharePoint 2013 and SharePoint 2016
Hope this will be helpful to create web jobs in SharePoint online and also to how to deploy web jobs to Microsoft Azure.
You May Also like the Following SharePoint Tutorials: