Forum Discussion

RahulC2310's avatar
RahulC2310
Copper Contributor
Oct 27, 2024

How to monitor download and upload events in onedrive?

I'm looking for a reliable way to monitor file download and upload events in OneDrive. Are there specific Microsoft Graph API endpoints, audit logs, or other tools within Microsoft 365 that can help track these actions? Any advice on configurations, permissions, or best practices to ensure effective monitoring would be greatly appreciated!

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    RahulC2310 

    To monitor file download and upload events in OneDrive for Business within Office 365, you can use several tools and APIs provided by Microsoft. Below are the key methods to effectively track these actions:

    1. Microsoft Graph API

    Microsoft Graph API is a powerful way to interact with Microsoft 365 services, including OneDrive. You can use it to monitor various events related to files and folders. Here are some key endpoints you might find useful:

    • Get Changes to a Drive Item:
      • You can use the delta endpoint to track changes (including uploads and downloads) to files in a user's OneDrive.
      • Endpoint:

    GET /me/drive/root/delta

      • This will return a snapshot of the changes since the last call.
    • Audit Logs via Microsoft Graph:
      • You can access the audit logs that include file operations through the /auditLogs endpoint.
      • Endpoint:

    GET /auditLogs/directoryAudits

      • This provides detailed audit logs including activities related to OneDrive.

    2. Microsoft 365 Compliance Center

    Microsoft 365 Compliance Center provides a comprehensive interface for monitoring user activities, including file uploads and downloads. You can find the following options:

    • Audit Log Search:
      • Go to Microsoft 365 Compliance Center > Audit.
      • You can filter events to show activities related to OneDrive, such as file downloads, uploads, and deletions.
      • You need to ensure that audit logging is turned on for your organization.

    3. SharePoint Online Management Shell

    You can use the SharePoint Online Management Shell to run PowerShell commands that help manage and retrieve reports related to OneDrive activities:

    • Example Command:

    powershell

    Get-SPOSite -Identity "https://yourtenant-my.sharepoint.com/personal/user_domain_com" | Select-Object LastContentModifiedDate

    This command retrieves the last modified date of the OneDrive site.

    4. Configurations and Permissions

    Permissions Required

    To use Microsoft Graph API for accessing OneDrive activities, you will need specific permissions:

    • Delegated Permissions:
      • Files.Read.All (for reading files)
      • AuditLog.Read.All (to access audit logs)
    • Application Permissions (for app-only access):
      • Files.ReadWrite.All
      • AuditLog.Read.All

    Make sure that the account or application using the API has these permissions granted in the Azure portal.

    5. Best Practices for Monitoring

    • Enable Audit Logging: Ensure that audit logging is enabled for your organization. This will allow you to track changes effectively.
    • Regularly Review Audit Logs: Set a schedule to regularly review the audit logs to stay updated on file activity.
    • Set Up Alerts: You can configure alerts in the Microsoft 365 Compliance Center to notify you of specific activities, like large file uploads or downloads.
    • Use Graph API Delta Queries: Utilize the delta queries to keep track of changes efficiently without polling constantly, reducing overhead on your API calls.

    Summary

    To monitor download and upload events in OneDrive for Business effectively:

    1. Utilize the Microsoft Graph API for detailed event tracking.
    2. Use the Microsoft 365 Compliance Center for audit log searches and to ensure audit logging is enabled.
    3. Consider the SharePoint Online Management Shell for scripting and automation of reports.
    4. Ensure the necessary permissions are set for the users or applications accessing the APIs.

    By combining these tools and strategies, you can create a robust monitoring solution for file activities in OneDrive.

     

    NOTE: My knowledge of this topic is limited, but since no one has answered it for at least one day or more, I entered your question in the AI. The text and the steps are the result of AI. Maybe it will help you further in your project, if not please just ignore it.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

Resources