I am working on a sharepoint online team site collection. and i want to define a job which runs on daily basis to do the following:-
- Integrate with SharePoint REST API, to get all the items inside a certain list which have their Due Date = Today.
- send an email to a sharepoint group.
Now when i was working on such a task inside SharePoint on-premises, i use to follow this approach :-
1- I create a .net console app which integrate with SharePoint REST API, get the related items, and finally send the email using .NET WebClient
, something as follow :-
//do the checks then send an email to the related group
using (MailMessage myMailMessage = new MailMessage())
{
SPOutboundMailServiceInstance smtpServer = currentsite.WebApplication.OutboundMailServiceInstance;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(smtpServer.Server.Address);
myMailMessage.IsBodyHtml = true;
myMailMessage.Subject = subject;
myMailMessage.Body = body;
smtp.Send(myMailMessage);
//code goes here..
}
2- place the console application on the sharepoint server.
3- using windows task scheduler tool, i create a task which executes the console application on daily basis (@1:00 am for example).
so now in sharepoint online i am not sure how i can host my console application + how i can schedule it ?. i already converted all my code inside the console application to use the client-side module instead of server-side module. but my question is about hosting & scheduling the console application. i read about these options inside Azure mainly :-
- WebJobs
- Azure Functions
but i am not sure which appraoch is better to follow ? and which of the 2 tools mimic the appraoch of scheduling the console application using windows tasks scheduler?. now i read this article https://anthonychu.ca/post/azure-functions-scheduled-executables/ about Azure functions, but i got confused on what does function.jso
file do? and not sure if i can run standard console application using these tools? also is there a UI to configure the trigger schedule as in the windows tasks scheduler case?
Thanks