Export D365 F/SCM Data Packages to SharePoint for Power BI with Power Automate
2. December 2026 Leave a comment
A customer running Dynamics 365 Supply Chain Management wanted a few Power BI reports on top of their ERP data. They didn’t need near-real-time numbers: a daily refresh was fine. Instead of setting up Synapse Link, Fabric or BYOD, I went with something simpler. I reused the data export projects they already had in the Data Management workspace and let Power Automate do the rest.
The result is three scheduled flows. They start a data package export, wait until D365 has finished it, then download the package and unzip it into a SharePoint document library. Power BI reads the CSV files from SharePoint. No Azure resources, no custom X++ code.
The idea to call the Data Management package API directly over HTTP isn’t mine. Vijay Yelmame showed it with Postman in his post Data management package REST API – Export package in Dynamics 365 FO using Postman on the Dynamics 365 Community. That post was my starting point. This article shows how to turn those Postman calls into an unattended solution with Power Automate.
How the Data Management package API works
The export is asynchronous. You tell D365 to run an export project, D365 queues a batch job, and you get nothing back except an acknowledgement. You have to ask again later whether the job has finished. Only then can you request a download link for the package.
That makes three OData actions, all on the DataManagementDefinitionGroups entity and all called with POST:
| Step | Action | Body | Returns |
|---|---|---|---|
| 1. Start | ExportToPackage | definitionGroupId, packageName, executionId, reExecute, legalEntityId | The execution ID |
| 2. Poll | GetExecutionSummaryStatus | executionId | Status, e.g. Executing, Succeeded, Failed |
| 3. Fetch | GetExportedPackageUrl | executionId | A time-limited blob URL (SAS) for the ZIP package |
The full URL is https://<your-environment>.operations.dynamics.com/data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.<Action>.
The execution ID ties the three calls together. You can pass your own ID to ExportToPackage, which means you know it before the export even starts. That is what makes splitting the process across several flows easy.
Microsoft documents all actions in Data management package REST API. According to Microsoft Learn, the exported file stays in blob storage for seven days before it is deleted automatically.
Architecture: three flows and a SharePoint list as the glue
Each of the three API steps gets its own flow. A SharePoint list keeps track of every export run and its state, so the flows never call each other directly.
Architecture: three scheduled flows between the D365 package API and SharePoint
| Flow | Schedule | Picks up | Does |
|---|---|---|---|
| 01 Data Export | Daily, 3 am | Every row in the package list | Starts the export, writes a history row |
| 02 Check Export Status | Daily, a few minutes later | History rows with Ready = No | Polls the status, sets Ready = Yes on success |
| 03 Download Package | Daily, 4 am | History rows with Ready = Yes and Started = No | Downloads the ZIP, extracts it, sets Finished = Yes |
Why not one flow with a Do-until loop? A few reasons:
- The API is asynchronous anyway. Waiting inside a flow means a run sits there for minutes or hours doing nothing. A scheduled flow that looks at a list fits the API much better.
- Fault isolation. If one run fails, for example because the download hits a timeout, the other steps and the other packages are not affected. The next run simply picks up what is left.
- Easier support. When something breaks, you see immediately which step failed, and for which execution ID. Debugging one 40-action “monster flow” is a lot less fun.
- Not time-critical. The reports refresh once a day. Nobody cares whether the data lands at 4:00 or 4:30.
The SharePoint site holds three things:
- Export Pakete (German for export packages): a list with one row per D365 export project. The Title must match the data project name in D365 exactly. Adding a new export for Power BI means adding a row here, no change to the flows.
- Export History: one row per export run with Title, Execution ID and three Yes/No columns: Ready, Started and Finished. These flags form a small state machine. They also double as a log you can read without opening Power Automate.
- Export Downloads: a document library where the extracted packages end up, one folder per package and one subfolder per run.
The Export Pakete list: one row per D365 export project
The Export History list: every run with its execution ID and status flags
One more design decision: all D365 calls use the plain HTTP action, not the Fin & Ops connector. The connector does not offer the package API actions, so we call the OData actions ourselves and handle the OAuth token in the flow.
Prerequisites
- An export project in D365. In Data management, create an export data project with the entities you need, e.g.
Customers V3in CSV format. Its name is thedefinitionGroupIdthe API expects. - An app registration in Microsoft Entra ID with a client secret. No API permissions are needed for the client credentials flow against Fin & Ops.
- The app registered in D365. Go to System administration > Setup > Microsoft Entra applications, add the client ID and map it to a user who may run data projects.
- A SharePoint site with the two lists and the document library described above.
- A Power Automate Premium licence (or a per-flow plan) for the flow owner, because the HTTP action is a premium connector.
In D365, the job history in the Data management workspace shows every run triggered by the flows, just as if you had clicked Run project yourself.
Export project and job history in the D365 Data management workspace
Getting a bearer token with the HTTP action
All three flows start the same way. They first read their SharePoint list. If the list has nothing to work on, the flow ends there without requesting a token. An idle run costs a single SharePoint call.
The token comes from the Entra ID v2 endpoint using the client credentials grant:
- Method: POST
- URI:
https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token - Header:
Content-Type: application/x-www-form-urlencoded - Body (expression):
concat( 'grant_type=client_credentials&client_id=', variables('V_ClientID'), '&client_secret=', variables('V_Client_Secret'), '&scope=https://<your-environment>.operations.dynamics.com/.default')
A Parse JSON action with this schema reads the response, and Set variable stores access_token in V_Bearer_Token:
{ "type": "object", "properties": { "token_type": { "type": "string" }, "expires_in": { "type": "integer" }, "ext_expires_in": { "type": "integer" }, "access_token": { "type": "string" } }}
Every call to D365 then carries the header Authorization: Bearer @{variables('V_Bearer_Token')}. A condition checks that the token variable isn’t empty before the main loop runs.
Flow 1: Start the export
Flow 1 reads the package list and starts one export per row. It runs on a daily recurrence trigger.
- Initialize the variables
V_ClientID,V_Client_Secret,V_Bearer_TokenandV_Execution_Id. - Get items from the Export Pakete list.
- If the list isn’t empty, get the bearer token as shown above.
- Apply to each row of the list:
- Set
V_Execution_Idto a new, unique ID:concat('PBix-', guid()). The prefix makes these runs easy to spot in the D365 job history. - Call
ExportToPackagewith the HTTP action. - Create a row in Export History with the title, the execution ID and Ready, Started and Finished set to No.
- Set
Flow 1 with the HTTP action that calls ExportToPackage
The HTTP action posts to .../data/DataManagementDefinitionGroups/Microsoft.Dynamics.DataEntities.ExportToPackage. The body uses the list item’s title as both project name and package name:
{ "definitionGroupId": "@{items('For_each')?['Title']}", "packageName": "@{items('For_each')?['Title']}", "executionId": "@{variables('V_Execution_Id')}", "reExecute": false, "legalEntityId": "<your legal entity>"}
legalEntityId is the company the export runs in. If you export from several companies, add a column to the package list and use that instead of a fixed value.
Flow 2: Check the export status
Flow 2 asks D365 how each open export is doing and flags the finished ones as ready.
- Get items from Export History with the OData filter
Ready eq 0. - If there are any, get a bearer token.
- Apply to each history row:
- Call
GetExecutionSummaryStatuswith the row’s execution ID. - Parse the response.
- If the status is
Succeeded, update the row and set Ready to Yes.
- Call
Flow 2 polls GetExecutionSummaryStatus and sets Ready
The request body is just the execution ID:
{ "executionId": "@{items('For_each')?['ExecutionID']}" }
The response is a plain OData value, so the Parse JSON schema is short:
{ "type": "object", "properties": { "@odata.context": { "type": "string" }, "value": { "type": "string" } }}
The condition compares body('Parse_JSON_execution_state')?['value'] with Succeeded. Rows that are still Executing stay at Ready = No and are checked again on the next run.
Flow 3: Download and extract the package
Flow 3 downloads every ready package and unpacks it into the SharePoint library.
- Get items from Export History with the filter
Ready eq 1 and Started eq 0. - If there are any, get a bearer token.
- Apply to each history row:
- Set Started to Yes right away, so the row is not picked up twice.
- Call
GetExportedPackageUrlwith the execution ID and parse the response. Itsvalueis the download URL. - Create new folder in Export Downloads:
<package name>/<timestamp>. - Download the ZIP with a second HTTP action:
GETon the URL from step 2. No Authorization header here, because the URL already contains a SAS token. - Create file
<execution ID>.zipin the new folder, with the HTTP response body as content. - Extract folder (SharePoint connector) unpacks the ZIP into the same folder, with Overwrite on.
- Delete file removes the ZIP.
- Set Finished to Yes.
Flow 3 downloads the ZIP, extracts it and updates the history row
The folder path keeps each run separate and sorts by date:
concat( items('For_each')?['Title'], '/', convertFromUtc(utcNow(), 'W. Europe Standard Time', 'yyyy-MM-dd_HH-mm-ss'))
After a run, each folder holds the entity file (e.g. Customers V3.csv) plus the Manifest.xml and PackageHeader.xml that every DMF package contains.

An extracted package in the Export Downloads library
Reading the data in Power BI
In Power BI, use the SharePoint folder connector on the site and pick the newest file of each entity. Because the folder names are timestamps in yyyy-MM-dd_HH-mm-ss format, sorting by folder path is enough. Here is a sketch in Power Query:
let Source = SharePoint.Files("https://<tenant>.sharepoint.com/sites/<site>", [ApiVersion = 15]), Files = Table.SelectRows(Source, each Text.Contains([Folder Path], "/DX_CUSTOMERS/") and [Name] = "Customers V3.csv"), Latest = Table.First(Table.Sort(Files, {{"Folder Path", Order.Descending}})), Csv = Csv.Document(Latest[Content], [Delimiter = ",", Encoding = 65001, QuoteStyle = QuoteStyle.Csv]), Result = Table.PromoteHeaders(Csv, [PromoteAllScalars = true])in Result
Once the semantic model is published, schedule its refresh in the Power BI service after Flow 3 has run.
Lessons learned and tips
- Keep the client secret out of the flow. For a quick start, a variable works. For production, read the secret from Azure Key Vault or a secret-type environment variable. Also turn on Secure inputs and Secure outputs on the token action, so neither the secret nor the token shows up in the run history.
- Handle more than
Succeeded. The status can also beFailed,PartiallySucceededorCanceled. If you only check for success, a failed export stays in the queue and is polled forever. Add a Failed flag, or an error column, and send a notification. - Watch out for variables in loops. Apply to each runs in parallel by default, and variables are global to the flow. Either set the loop’s concurrency to 1 or generate the execution ID in a Compose action inside the loop.
- Download right after asking for the URL. The package URL contains a SAS token that expires, and the file itself is removed from blob storage after seven days. Flow 3 therefore fetches the URL and downloads in the same run.
- Poll more often if you need to. Flows 2 and 3 only do real work when the history list has open rows. Running them every 15 or 30 minutes costs almost nothing and gets the data to SharePoint sooner.
- Clean up both ends. Use Job history cleanup in D365, and a retention policy or a small extra flow for old folders in the SharePoint library.
- Restart by editing the list. If a download fails, set Started back to No in the history list and Flow 3 picks the row up again on its next run. Support doesn’t need to touch the flows.
Conclusion
With three small flows, two SharePoint lists and one document library, you get a daily, unattended export from D365 F/SCM into Power BI. You don’t need Azure or custom code, and you can use the export projects you already have. Adding another dataset is a new row in a list. Because each step runs on its own, a failed run is easy to find and easy to restart.
Thanks again to Vijay Yelmame for the Postman walkthrough that started it all.
Links
- Vijay Yelmame: Data management package REST API – Export package in Dynamics 365 FO using Postman
- Microsoft Learn: Data management package REST API
- Microsoft Learn training: Implement the Data management package API for finance and operations apps










