Microsoft Graph API to scan my organizations OneDrive take very long time.

Allagadda Sai Upendranath 0 Reputation points
2024-01-19T06:51:25.4633333+00:00

I am using Microsoft Graph API to scan permissions of resources in my organization OneDrive. It contains almost 20 million objects. It takes many days to completely retrieve info on permissions. Can you please suggest how I can optimize or is there any other way to do this quicker?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,890 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
715 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Diah.Karim-MSFT 320 Reputation points Microsoft Vendor
    2024-01-22T02:05:21.17+00:00

    Hi Allagadda,

    I believed you are using one of the endpoint as below link to loop through the list of permissions info for each files, right? Potentially this endpoint /sites/{siteId}/drive/items/{itemId}/permissions

    https://learn.microsoft.com/en-us/graph/api/driveitem-list-permissions?view=graph-rest-1.0&tabs=http

    There are couple of approaches that can be done to improve the performance of getting info about permission for each item.

    1. Query Parameters - This will help you achieve multiple tasks such as limiting the amount of data returned by requests to Microsoft Graph such as controlling how many fields are returned for each record, how many records are returned, also filtering and searching for wanted information.
    2. Reduce traffic with batched requests - Use batch requests Microsoft Graph to execute multiple requests and return the grouped results for each request in a single response. Batching doesn't reduce the number of requests, but it does reduce the number of HTTP round trips your application requests to Microsoft Graph.

    More details refer to this link https://learn.microsoft.com/en-us/training/modules/optimize-data-usage/

    More info regarding batches request - https://learn.microsoft.com/en-us/graph/json-batching Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments