Azure Function to update SharePoint list Items by CSOM does not update elements via the SystemUpdate method

Przemysław Szymkowiak 0 Reputation points
2024-03-01T08:49:34.6866667+00:00

I created an Azure function in C#, which has been working so far through SharePoint app-only ACS, and now I tried to switch it to Azure AD app-only. So something like this https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread. We did the following:

  • Registered the app
  • Added permissions to the site for this app
  • Added a self-signed certificate

Now, I'm getting the context locally like this using the certificate I have on my computer:

var certificate = new X509Certificate2(pfxFilePath, pfxPassword); var authManager = new AuthenticationManager(ClientId, certificate, TenantID); var context = authManager.GetContext(SiteUrl);

Unfortunately, since I've been using this app locally with Azure AD App-only, I can't perform SystemUpdate in CSOM i have error:

Message = "Attempted to perform an unauthorized operation."

Surprisingly the Update method works.

With the old way of obtaining the context, using SharePoint app-only ACS:

ar context = new AuthenticationManager().GetACSAppOnlyContext(SiteUrl, ClientId, Secret);

both methods to update SharePoint ListItem targetitem.Update() and targetitem.SystemUpdate() works!.

Has anyone encountered this or is this a limitation? There's nothing written in the documentation about this. It's strange that when changing the way of obtaining the context, you can't execute the SystemUpdate() method.

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
4,746 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,574 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.