From the choices above I have chosen SharePoint CSOM (Client Side Object Model) to this sample but if you prefer JSOM or REST API with the requirement, you could go with those.
Lets checkout Azure Functions with SharePoint Online where both in same cloud group which call as SaaS (Software as a Service).
🛠 Step ♳ – Create an Azure Function
You could arrive there with simply following below reference which is common thing and described in every reference.
🛠 Step ♴ – Adding SharePoint CSOM DLLs
To add SharePoint DLLs to Functions App environment, you required to arrive with Kudu environment.
Function à Platform Features à Advanced Tools (Kudu)
⚡ Shortcut – You could arrive there with URL
After you arrived with Kudu portal, check for debug then PowerShell (Command prompt is also available but prefer PS). Navigate to bin folder which resides under following location under you function name and upload your SharePoint DLLs to the folder (i.e. Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll)
☕ Learn more on Kudu – https://github.com/projectkudu/kudu
🛠 Step ♵ – Refer SharePoint references on the Function
After adding DLLs to the bin, you could arrive with function and start writing you logic within the run.csx.
You could refer added DLLs in the function as below in the top.
🛠 Step ♶ – Imports references
This is typical step we are doing in any C# which is adding references.
🛠 Step ♷ – Configuration Values in Azure Function
You will be required the user name, password, and site URL to your SharePoint, those could be done with the application settings as we were keep doing with the web.config files.
Navigate thorough below path and add your configurations where you will be references in function logic.
Click on Function à Platform Features à Application Settings à App settings à Add values as key/ value pairs
Above could be accessed as below in the code.
string userName = ConfigurationManager.AppSettings[“User”];
🛠 Step ♸ – Application Logic
You could write as your preference. In my sample on the gist which I have posted below is considered copying list items from one list to another. It’s really simple and you could able to expand the logic as you have done earlier with SharePoint CSOM.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You could use Azure Functions as Timer Jobs (which we had in SharePoint Server) with scheduling and web hooks and etc.
References – Azure Function Developer Guide