In Office 365/SharePoint Online we can no longer create traditional full trust solutions. This limitation also takes away the capability of creating custom timer jobs as full trust solutions.

 

 

The recommended approach is now to create the remote timer jobs. When it comes to remote timer jobs we have few options are there are no set standards.

In this article, we will see how to use PnP and Azure Webjobs to the create the remote timer job.

SharePoint Patterns and Practices (PnP) is an open source initiative coordinated by SharePoint engineering. It’s a channel for the SharePoint engineering to share documentation, guidance, samples and reusable component for the community. PnP initiative coordinates all SharePoint developer documentation and guidance across on-premises and online. Day to day work is coordinated by the PnP Core team, which consists of Microsoft internal people and external MVPs.

 

Step#1: Create a console application

1. Console application

Step#2: Get the PnP package

2. Get SharePoint Pnp

Step#3: Update the code as shown below

 

Step#4: Run the program

6. Output

 

Step#5: Create a website in Azure

3. Azure web site

13. Website

Step#6: Register an app(ClientId and Client secret is removed)

4. Register app

Step#7: Grant required permission to the app

 

5. Grant Permission

Step#8: Update the program to use the app credentials 

 

and have your client ID and secret in the “App.config”

 

 

Step#9: Publish as Azure WebJob

7. Publish

Step#10: Connect and select the Azure website provisioned above

8. Select the web service 

Step#11: Check and make sure that it is published

10. 1. Published status

Step#12: Go to Azure portal, run the Webjob and check the logs.

9. Start the webjobs

10. Check logs

 

Step#13: It would fail as you have to make sure that all the references are marked  as “Copy Local”

11. Set all the reference as local copy

Step#14: Republish and rerun the Webjob

12. Rerun and check logs