I got back to active SharePoint and CSOM development some months ago and first thing to do was to port bunch of workflows from in-prem SharePoint to cloud. Where I live we don’t usually have any simple workflows. Most of them need some backing code due to custom logic. So, my only option was to go with Microsoft Flow or Azure Logic Apps and Azure Functions. Here’s the project with one dummy function to get started.
Are you new to Azure Functions? If yes, then you can read my posts Getting started with Azure Functions and Short introduction to serverless architecture to get better understanding of Azure Functions and serverless computing.
First of all – I was damn surprised to find out that CSOM doesn’t work with .NET Core and I have to use first generation of Azure Functions and .NET Framework 4.x (4.6.1 in my case). Here’s the project file that works for me.
<None Remove=".gitignore" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<Reference Include="Microsoft.CSharp" />
<HintPath>C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll</HintPath>
<HintPath>C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll</HintPath>
With .NET Framework come also .NET Framework classes and stuff that doesn’t work with .NET Core. Here’s the dummy function to use as a starting point for functions that talk to Office 365 SharePoint using CSOM.
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage request, TraceWriter logger)
logger.Info("C# HTTP trigger function processed a request.");
foreach (var key in request.GetQueryNameValuePairs())
logger.Info(key.Key + ": " + key.Value);
If you configure this function to use function key you can easily try it out directly from your browser. You can make this function synchronous if you don’t use asynchronous calls in CSOM.
Not all revenue generating services are supported on .NET Core yet and it was big surprise to me to see that CSOM is not available for .NET Core yet. There are third-party NuGet paclages available to make CSOM work with .NET Core but if you prefer to go with officially supported libraries then full .NET Framework is your only choice today.
View Comments (0)