Azure Functions are a very powerful auto upscaling server-less compute service provided by the Microsoft Azure cloud services.
Azure functions are provided in predominantly two major versions –
1.x targeting the standard .NET Framework
2.x targeting the .NET Core 2 version which further supports the macOS and Linux for cross platform development.
This specific example provides a simple overview into explaining the two different methodologies of Authenticating SharePoint-Online Client Object Model (CSOM) context with Azure Function :
- Using Azure Active Directory
- SharePoint Application Client Id and Secret. (AppRegNew.aspx)
Using Azure Active Directory :
One of the easiest ways to getting started into creating a HelloWorld project is via the Azure Portal, with a few clicks for configuring the Azure Storage, Resource Group for web apps, it scaffolds a API-Layer boilerplate code which supports GET and POST requests via HTTPS automatically provisioned and hosted under the .azurewebsites.net domain.
What we need is not only the API layer but also an external library for communicating with SharePoint Online, the Microsot.SharePoint.Client.dll.
The integration of external libraries is not trivial, as the “yourfunction.azurewebsites.net” is already hosted, and you need to upload the third party dlls into the wwwroot/bin folder to make it available for referencing and re-compiling it within your Function. To do this you need to open the KUDU portal for your web application from Azure portal, and upload any third party libraries under the wwwroot/bin folder. By referencing it via the “using” statement within your .csx file, the properties and methods are directly accessible within the Function along with intellisense.
The article from the famous Bob German (Technology Architect @Microsoft) has a 3 part series with detailed in-depth approach of how to get started – https://bob1german.com/2017/06/24/az-func-simplestart/
Leave a Reply