Hello Baojun Guo,
Thank you for contacting Microsoft!
To get the total size and number of files more efficiently, you can use the Microsoft Graph API with specific queries.
- Use the
siteUsage
API: This API provides storage usage details for SharePoint sites. You can call this API for each site collection to get the total storage used and then sum these values across all site collections. - Use the
driveItem
API with$select
and$expand
parameters. You can use these parameters to filter and expand the properties you need, which can help reduce the amount of data returned and make process more efficient.
For Drive Delta API to return only file info without directory information, you can use the deltaExcludeParent
header. This will ensure that only items that have changed are returned, excluding parent items in the hierarchy.
After trying the above work arounds, if you still face any issue, I recommend you to raise a support case with Microsoft Graph, a Support Engineer will be able to look into this issue and assist you better. You can raise support ticket from New support request - Microsoft Entra admin center or https://admin.microsoft.com/#/support/requests.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.