Description
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
SharePoint CSOM
Target SharePoint environment
SharePoint Online
What browser(s) / client(s) have you tested
- 💥 Internet Explorer
- 💥 Microsoft Edge
- 💥 Google Chrome
- 💥 FireFox
- 💥 Safari
- mobile (iOS/iPadOS)
- mobile (Android)
- not applicable
- other (enter in the "Additional environment details" area below)
Additional environment details
SharePoint online CSOM / REST API
Issue description
In chapter Application Throttling there is the following text:
SharePoint provides various APIs. Different APIs have different costs depending on the complexity of the API. The cost of APIs is normalized by SharePoint and expressed by resource units. Application’s limits are also defined using resource units.
We want to rate limit on the client side to avoid throttling by the server. Therefore we need to know how much each request will cost or has cost.
In particular we want to know Resource Unit of the following CSOM queries/actions:
- Context.Load(siteUsers, us => us.Include(u => u.Title, u => u.Id, u => u.LoginName, u => u.PrincipalType, u => u.Email, u => u.UserPrincipalName, u => u.AadObjectId));
- var refUserAsPrincipal = rootWeb.EnsureUser(logOnName);
- SecurableObjectSharePoint.Context.Load(refUserAsPrincipal, _user => _user.Email, _user => _user.LoginName);
- SecurableObjectSharePoint.ResetRoleInheritance();
- SecurableObjectSharePoint.BreakRoleInheritance(true, true);
- SecurableObjectSharePoint.Context.Load(SecurableObjectSharePoint, s => s.HasUniqueRoleAssignments);
- _spfile = ClientContext.Web.GetFileByUrl(AbsoluteUrl);
- ClientContext.Load(SPFile, f => f.TimeLastModified, f => f.Exists);
- ClientContext.Load(SPFile, f => f.Exists);
- ClientContext.Load(SPFile, f => f.Exists, f => f.TimeLastModified, f => f.MajorVersion, f => f.MinorVersion, f => f.Length, f => f.ListItemAllFields.Id, f => f.ListItemAllFields.ParentList.ForceCheckout, f => f.CheckOutType, f => f.CheckedOutByUser.UserPrincipalName, f => f.LockedByUser.UserPrincipalName, f => f.ListItemAllFields.HasUniqueRoleAssignments);
- ClientContext.Load(SPFile, f => f.ListItemAllFields.RoleAssignments.Include(rs => rs.Member, rs => rs.RoleDefinitionBindings.Include(rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
- ClientContext.Load(member, u => u.AadObjectId);
- ClientContext.Load(SPFile, f => f.Exists, f => f.ListItemAllFields.ParentList.Fields.Include(fld => fld.InternalName, fld => fld.FieldTypeKind), f => f.ListItemAllFields);
- ClientContext.Load(web, s => s.ServerRelativeUrl);
- ClientContext.Load(checkedoutedFile, f => f.Where(fi => fi.ServerRelativePath.DecodedUrl == fileRelativeUrl).Include(fi => fi.CheckedOutBy.Email));
- SPFile.CheckIn(comment, (CheckinType)checkinType);
- SPFile.CheckOut();
- SPFile.UndoCheckOut();
- SPFile.DeleteObject();
- var mstream = SPFile.OpenBinaryStream();
- ClientContext.Load(SPFile, r => r.ListItemAllFields.HasUniqueRoleAssignments);
- ClientContext.Load(SPFile, r => r.ListItemAllFields.ParentList.ParentWeb.RoleDefinitions.Where(rd => !(rd.RoleTypeKind == RoleType.Guest || rd.RoleTypeKind == RoleType.RestrictedGuest)).Include(rd => rd.Name, rd => rd.BasePermissions, rd => rd.RoleTypeKind));
- ClientContext.Load(SPFile, r => r.ListItemAllFields.RoleAssignments.Include(ra => ra.Member.LoginName, ra => ra.Member.PrincipalType, ra => ra.Member.Id, ra => ra.RoleDefinitionBindings.Include(rdb => rdb.Id, rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
- ClientContext.Load(SPFile, _file => _file.Exists, _file => _file.ListItemAllFields.ParentList.Fields.Include(_field => _field.InternalName, _field => _field.ReadOnlyField, _field => _field.FieldTypeKind), _file => _file.ListItemAllFields.ContentType.Name);
- var uploadFile = folder.Files.Add(newfile); ClientContext.Load(uploadFile);
- bytesUploaded = uploadFile.StartUpload(uploadId, startStream);
- uploadFile = uploadFile.FinishUpload(uploadId, fileoffset, finishStream);
- bytesUploaded = uploadFile.ContinueUpload(uploadId, fileoffset, continueStream);
- uploadFile.CancelUpload(uploadId);
- site.Context.Load(oWeb, w => w.Title, w => w.Language, w => w.Url, w => w.Navigation.UseShared, w => w.Description, w => w.AllProperties, w => w.HasUniqueRoleAssignments, w => w.ServerRelativeUrl, w => w.Id);
- site.Context.Load(oWeb, w => w.RoleAssignments.Include(ra => ra.Member.LoginName, ra => ra.Member.Id, ra => ra.RoleDefinitionBindings.Include(rdb => rdb.Id, rdb => rdb.RoleTypeKind, rdb => rdb.Name)));
- site.Context.Load(oWeb, r => r.RoleDefinitions.Where(rd => !(rd.RoleTypeKind == RoleType.Guest || rd.RoleTypeKind == RoleType.RestrictedGuest)).Include(rd => rd.Id, rd => rd.Name, rd => rd.BasePermissions, rd => rd.RoleTypeKind));
We want also know the points for more complex calls/actions, such as creating or updating lists, contenttypes, lists, site columns.
We now have made estimations what each call will probably costs based on the Graph API call costs table with values 1,2 or 5
If there is a way to return the actual resource unit costs of each action/query in the response headers, that would be awesome. We then can implement rate limiting on the client side with actual values.
The Metered API charges on price per 1000 requests (thus not on points). We therefore cannot use the metered (pay-per-use) API to determine the points per request.
Can you assist us to clarify the Resource Unit costs of the CSOM operations/queries?