Azure Function to update SharePoint list Items by CSOM does not update elements via the SystemUpdate method
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.