Document Sync Demo
Demo flow that watches a source SharePoint document library and replicates new and modified files to a destination location (OneDrive folder or another SharePoint library), preserving metadata and handling conflict cases.
Provided as-is, without warranty of any kind. Review and test each pattern in a non-production environment before deploying it to live automations. See our Terms.
Overview
This demo flow watches a configured SharePoint document library and replicates new files to a OneDrive for Business folder, preserving folder structure and enforcing a maximum file size. On success it sends a confirmation email; on size overrun it sends a "file too large" notice; any unexpected error in the copy path drops into a Scope-level error handler that sends a sync-failure email. Use it as a reference pattern for cross-store document mirroring with size guardrails and operator notifications.
Use Case
Teams often need a copy of SharePoint library content mirrored into a personal/team OneDrive for offline editing, sharing with external partners who don't have site access, or for an Office app that integrates more cleanly with OneDrive than SharePoint. Doing this by hand is error-prone and silently fails when files exceed quotas. This flow automates the copy, fails loudly via email, and keeps an audit trail in the Outlook Sent Items folder.
The flow is ideal for teams that:
- Real-time replication — files land in OneDrive as soon as they're created in SharePoint.
- Configurable max file size guard prevents quota blowouts.
- Error-handling Scope catches unexpected failures and emails the operator.
- Three notification paths (success, too-large, failure) make audits easy.
- All site/library/folder values driven by environment variables — no edits to redeploy.
Flow Architecture
When a File Is Created in Document Library
SharePoint OnNewFileFires whenever a new file is added to the watched library.
Init 5 variables
InitializeVariablevarSharePointSiteUrl, varDocSyncLibraryId, varOneDriveSyncFolder from env vars; varNotificationEmail and varMaxFileSizeMB hardcoded inside the flow.
Check File Size Within Limit
If conditionBranches on whether the file is under the size cap.
- Get File Content from SharePoint — Reads the file bytes.
- Extract Relative Folder Path — Compose — derives folder structure from trigger metadata.
- Build OneDrive Destination Path — Compose — concatenates the destination root and file name.
- Create File in OneDrive — Writes the mirrored file to the destination folder.
- Send Success Confirmation Email — Outlook SendEmailV2 confirming the copy.
Send File Too Large Email — Outlook SendEmailV2 with the file name and size.
Error Handling Scope
Scope (Run After failure)1 inner action: Send Sync Failure Email — fires when the upstream If branch fails.
Environment Variables
| Schema name | Type | Default | Description |
|---|---|---|---|
| flowlibs_SharePointSiteURL | String | — | Absolute URL of the source SharePoint site. |
| flowlibs_SharePointDocSyncLibraryID | String | — | GUID/identifier of the source document library to watch. |
| flowlibs_OneDriveSyncFolderPath | String | — | Destination folder path in the connection owner's OneDrive. |
Connectors & Connections
| Connector | API name | Actions used |
|---|---|---|
| SharePoint | shared_sharepointonline | OnNewFile (trigger) GetFileContent |
| OneDrive | shared_onedriveforbusiness | CreateFile (writes the mirrored file) |
| Office 365 Outlook | shared_office365 | SendEmailV2 (success / too-large / failure notifications) |
Note — All connections are referenced as solution connection references; the flow is portable between environments as long as a connection is mapped at import time.
Customization Guide
Almost every realistic variant of this flow can be implemented by changing environment variable values. A few cases require small edits inside the flow definition — those are called out explicitly below.
- Mirror to a SharePoint library instead of OneDrive
- Swap CreateFile for SharePoint's CreateFile, point the connection ref at the destination site, and update path-building.
- Promote varNotificationEmail to an env var
- Replace the InitializeVariable literal with parameters('flowlibs_NotifyEmail') and add the env var to the solution.
- Mirror updates as well as new files
- Add a parallel branch using When a file is modified (properties only) or move to a recurrence + delta-query pattern.
- Add a deny-list
- Insert a Filter Array or Condition before the copy that rejects file extensions like .exe or .zip.
- Replace email with Teams adaptive cards
- Swap the three Send Email actions for Post adaptive card in a chat or channel for ops alerts.
- Add throttling
- Wrap the True branch in a degree-of-parallelism setting (Concurrency control) to avoid hammering OneDrive when many files land at once.
Key Expressions
The flow is intentionally light on Power Fx / WDL gymnastics — the heaviest expressions are the branch-name concatenation and the approval outcome check. They are listed below in the order they appear in the flow.
EXPR.01Compare file size to limit
Used inside the size-guard If condition.
EXPR.02Build OneDrive destination path
Concatenates the destination root and the file name.
EXPR.03Trigger file content reference
Used as the source bytes for Create File in OneDrive.
Comments
Sign in to join the conversation.
Sign inNo comments yet. Be the first to share your experience with this flow.