Sync Oversized SharePoint Documents to Copilot Studio Knowledge via Power Automate
Bypass the 7 MB SharePoint limit by programmatically uploading files directly to your agent’s knowledge store.
When building a Copilot Studio agent, connecting to SharePoint is a natural first step for providing knowledge. However, the built‑in SharePoint connector can only ingest files up to 7 MB. Once you exceed that limit, you need a different approach: uploading the file directly to the agent’s knowledge store, which supports files as large as 512 MB.
Power Automate is the perfect orchestrator to bridge the gap. With a recurring scheduled flow, you can automatically sync a SharePoint document library to your Copilot agent, picking up only files that haven’t been added yet. In this article, we’ll build a complete automation that takes large PDFs—or any other supported document—from SharePoint and makes them available to your agent for question‑answering.
Scenario Overview
Imagine a legal department that stores annual compliance reports in a SharePoint document library. Many of these reports exceed 7 MB, so they cannot be added through the standard Copilot Studio SharePoint connector. The team wants to create a Copilot agent that can answer questions about these reports without manual file upload each time a new report lands.
We will:
- Create a Copilot Studio agent (with generative orchestration) that will hold the knowledge.
- Set up a SharePoint document library containing large PDF files.
- Build a Power Automate scheduled flow that:
- Queries the agent’s current knowledge.
- Finds newly added files in SharePoint.
- Uploads each new file to the agent’s knowledge.
- Publishes the agent so the changes take effect.
The same flow can later be extended to also remove files that were deleted from SharePoint.
Prerequisites
- A Power Platform environment with a licensed user (Premium) or a service principal that has access to Dataverse.
- Copilot Studio agent created in the same environment.
- A SharePoint site with a document library that contains at least one file > 7 MB.
- Permission to create and run Power Automate flows (with Dataverse connectors).
- The solution publisher prefix for your environment (you can find it in Solutions → Default Solution → Publisher).
Step 1: Create the Copilot Agent and the Document Library
Begin by navigating to Copilot Studio and creating a new agent.
- Name: Compliance Reports Agent
- Description: “Answers questions based on annual compliance report PDFs.”
- Mode: Generative orchestration (this allows the agent to use uploaded knowledge files).
Do not add any knowledge source yet; we will add everything through Power Automate.
Next, go to SharePoint and create a new document library called ComplianceDocs. Upload a few PDF files that are larger than 7 MB each (or at least one large file so the flow has something to process).
Step 2: Build the Power Automate Scheduled Flow
In Power Automate, create a new scheduled cloud flow that runs once a day (or any frequency that fits your update cycle). Give it a name such as Sync Large Compliance Docs to Agent.
Step 2.1: Get the Agent’s Unique Identifier
Add a Dataverse List rows action and select the Copilots table. Filter the rows to find your agent.
name eq 'Compliance Reports Agent'
Then initialize a string variable (let’s call it varAgentId) and set its value with the following expression:
first(outputs('List_rows_-_Copilots')?['body/value'])?['botid']Step 2.2: Retrieve Existing Knowledge Files from the Agent
Add another Dataverse List rows action, this time on the Copilot Components table. Use a filter that returns only rows belonging to your agent.
_parentbotid_value eq variables('varAgentId')Now use a Select action to create a simple array of filenames that are already known. The input is the list rows result; you can map the name field (or a custom attribute if you store the filename differently). For simplicity, we will rely on the name column that holds the filename with extension.
{
"Map": {
"FileName": "@{item()?['name']}"
}
}The output of the Select action will be an array of objects. We only need the filenames, so later you might use a Compose or directly use the array in a Filter Array condition.
Step 2.3: Identify New Files in SharePoint
Add a SharePoint Get files action (or List folder) on the ComplianceDocs library. Then use a Filter Array action to compare the SharePoint file list against the array of existing filenames.
- From: output of the Get files action (list of files).
- Condition:
{FilenameWithExtension}is not in the array from the Select action.
Because the Filter Array expects a simple array of values, you might need to use an expression to extract the array. If you have an array of objects, you can create an array of strings first. A clean way is to use a Select with the expression item()?['{FilenameWithExtension}'] and then pass that result to the Filter Array’s To property.
If the Select action returns an array of objects, use another Select or a Compose with outputs('Select')?['value'] to get just the FileName values. Alternatively, flatten with a Apply to each.
Step 2.4: Process Each New File
Insert an Apply to each action that loops over the filtered array output (the new files). Inside the loop, add these actions:
- Get file content from SharePoint (use the Identifier of the current item).
- Add a new row to the Dataverse Copilot Components table.
Configure the “Add a new row” action as follows:
- Table: Copilot Components
- Component type:
Bot File Attachment - SchemaName: Use a name that follows the pattern
{publisherPrefix}_{agentLogicalName}.file.{filenameWithExtension}. ReplacepublisherPrefixandagentLogicalNamewith values from your environment.
crxyz_complianceReportsAgent.file.@{items('Apply_to_each:_New_Files')?['{FilenameWithExtension}']}- Parentbotid (Lookup):
/bots(@{variables('varAgentId')})
After the row is created, you need to upload the actual file content. Use a Upload a file or an image action (Dataverse connector) and target the same Copilot Components table. Set:
- Row ID: The
botcomponentidreturned by the add row action. - Column name:
filedata - Content: The file body from the Get file content action.
The uploaded file cannot exceed 512 MB. If your SharePoint files exceed that limit, you must split them first. Dataverse itself may have additional size limits for binary columns; check your environment settings.
Step 2.5: Publish the Agent
After the loop completes (or even after the whole flow), the agent must be published to make the changes visible in channels. Add a Dataverse Perform a bound action action.
- Table: Copilots
- Action:
PvaPublish - Row ID:
variables('varAgentId')
Step 3: Test the End‑to‑End Flow
Save and run the flow manually. It should:
- Fetch your agent’s ID.
- List current knowledge files (likely empty on first run).
- Identify all files in the SharePoint library.
- Upload each one to the agent’s knowledge.
- Publish the agent.
After a successful run, go back to your Copilot agent. In the Knowledge tab you should see the files listed, first with a status of “In progress” and later “Ready”. Open the test chat pane and ask a question that relies on the newly uploaded document. The agent should be able to answer correctly.
Security and Performance Notes
- Permissions: The flow runs under the user or service principal that owns it. Ensure that identity has read access to the SharePoint library and write access to the Dataverse Copilot Components table.
- Dataverse throttling: If you are uploading many files in one run, consider adding delays or batching. The default service limits may apply.
- Publisher prefix: The
SchemaNamemust start with your solution publisher prefix (e.g.,crxyz_). Prefix mismatches will cause row creation failures. - Flow duration: Large files can cause the flow to run for several minutes. The synchronous action timeout is typically 2 minutes for a single HTTP request; the overall flow can run up to 30 days. If you upload many huge files, split the work across multiple runs or use a parallel branch if the connector supports it.
Common Mistakes and Troubleshooting
- Missing publish step: The agent will not reflect the new knowledge until
PvaPublishis called. Always include the bound action. - Wrong parentbotid value: The lookup must be in the format
/bots({guid}). Double‑check the variable. - Duplicate uploads: Make sure the Filter Array condition correctly excludes already‑known files. Check the Select action output is a simple array of strings for the “is not in” test.
- SchemaName collisions: If you run the flow again with the same filenames, the “Add a new row” will fail because the
SchemaNamemust be unique. The filter should prevent that, but if you accidentally remove the filter you will get a duplicate error. - Large file timeouts: The “Upload a file or an image” action may fail on files near the 512 MB limit. Test with a moderately large file first.
Removing Files That Were Deleted from SharePoint
To keep the agent’s knowledge fully synchronized, you may also want to delete files that have been removed from SharePoint. This is an extension of the same flow.
After the “Publish” action, add:
- A Select action that gets all filenames from the SharePoint library (full list).
- A Filter Array on the existing agent knowledge (from step 2.2) where the filename is not in the SharePoint list.
- An Apply to each over the filtered array, with a Dataverse Delete a row action on the Copilot Components table using the
botcomponentid. - Finally, repeat the Publish action so deletions take effect.
By combining both addition and deletion, you create a bidirectional sync that keeps the agent’s knowledge store in line with your document library.
Final Recommendation
Automating the upload of large SharePoint files to Copilot Studio with Power Automate is a robust workaround for the 7 MB connector limitation. It gives you full control over the schedule and the ability to handle files up to 512 MB. The flow can be expanded to support incremental syncs, notifications, or even custom metadata tagging.
If you plan to use this in production, be sure to monitor Dataverse API limits and set up appropriate error handling (for example, using a Scope with Configure run after inside the Apply to each). The solution is especially valuable for enterprise compliance, legal, or research teams that work with oversized documents.
References
- Original reference: How To Add Copilot Studio Knowledge Files Using Power Automate by Matthew Devaney
- Microsoft Learn: Add files to Copilot Studio knowledge
- Microsoft Learn: Solution publisher prefix
Core principles for resilient, maintainable, and efficient cloud flows, distilled from real-world implementations.
Build flows that gracefully handle failures and automatically notify you with run details.
Discover the trade-offs between Content-ID, Base64, and the Microsoft Graph API for embedding images in Power Automate emails. This guide covers which method works best for Outlook, Gmail, and more.