They Said It Couldn't Be Done: Copying a Database from PPAC to a Tier-1 DevBox
For years, Dynamics 365 Finance and Operations teams relied on a familiar database workflow in Lifecycle Services (LCS): refresh Production to a Sandbox, export the database as a .bacpac, and import it into a Tier-1 DevBox. This gave developers access to realistic transactions, configurations, and edge cases for debugging.
Then came Power Platform Admin Center (PPAC). Instead of working with individual databases, we now have environment-level copies and cloud backups. And we kept hearing that exporting a database from a PPAC-managed environment and restoring it on a Tier-1 devbox was no longer possible.
Well, we weren't entirely convinced. So, we decided to give it a try. And it worked. :)
At SF Consulting, we developed an automated process that extracts databases from Unified Developer Environments (UDE) and Unified Sandbox Environments (USE), resolves compatibility issues, and imports them into SQL Server on Tier-1 DevBoxes.
It wasn't quite as straightforward as the old LCS approach, and we encountered a few interesting technical challenges along the way. Here's how we solved them.
An Automated Azure DevOps Pipeline
Our solution is built around an Azure DevOps pipeline and PowerShell scripts. It runs on a dedicated Tier-1 DevBox acting as the pipeline agent and uses a Microsoft Entra ID app registration to authenticate and access the PPAC environments.
The pipeline consists of three stages:
1. Requesting JIT Access and Exporting the Database
The pipeline first authenticates using the Microsoft Entra ID app registration configured for the target PPAC environment.
Once authenticated, it uses d365bap.tools to request Just-In-Time (JIT) access to the database:
The command returns temporary SQL credentials with the requested access role. In our environment, these credentials remain valid for 9 hours, with database access restricted to the authorized public IP address of the pipeline agent.
This automates the JIT access process that can also be performed manually through Power Platform Tools for Visual Studio. Once access is granted, the pipeline uses SqlPackage to connect to the Azure SQL database using the temporary JIT credentials and export its schema and data into a .bacpac file.
2. Preparing the bacpac model file
Our first attempts to import the exported .bacpac directly into SQL Server 2019 failed. Why SQL Server 2019? Because Microsoft still provides D365FO Tier-1 DevBox images through LCS that come with SQL Server 2019.
Although Azure SQL and SQL Server share the same foundation, the exported database contained several settings and objects that were incompatible with the SQL Server version used on these DevBoxes.
To address these issues, we added a dedicated pipeline stage that prepares the model.xml file from the .bacpac before import. This stage handles three compatibility issues:
- Query Store configuration. The exported model contained QueryStoreCaptureMode = 4 (CUSTOM), which caused the import to fail with the error "The option 4 for querystore query_capture_mode is not supported." In our tested configuration, changing the value to 2 (AUTO) resolved the issue.
- DAMSFinopsIndexCleanup procedure. The import also failed because the
[dbo].[DAMSFinopsIndexCleanup]procedure used theWAIT_AT_LOW_PRIORITYoption inCREATE INDEXstatements, which was not recognized by SQL Server 2019 on Tier 1 devbox. Since this procedure was not required for the development database, we removed it from the model. - Azure SQL-specific permissions. Another issue involved permissions associated with Azure SQL roles such as
ms_db_configreaderandms_db_configwriter. In particular, SQL Server rejected theKILL DATABASE CONNECTIONpermission as unsupported. We resolved this usingRepair-D365BacpacModelFilefromd365fo.toolsto remove the incompatible permissions.
After applying these adjustments, the pipeline uses the corrected model.xml during the SqlPackage import, while keeping the original .bacpac unchanged.
Modifying the .bacpac model.xml is a workaround rather than a standard Microsoft-supported migration method, but it has worked successfully for us.
3. Importing the Database
With the compatibility issues addressed in the previous stage, the pipeline can now import the .bacpac into SQL Server 2019 on the Tier-1 DevBox acting as the pipeline agent.
We use SqlPackage with the /ModelFilePath parameter to apply the corrected model.xml during import. Once the import is complete, we have a local copy of the PPAC database running on SQL Server 2019. Any further preparation, including data cleanup and backup creation, is handled separately and is outside the scope of this article.
Conclusion
We successfully tested this approach with both UDE and USE environments. Our Azure DevOps pipeline can extract a database from a PPAC-managed environment, resolve compatibility issues, and import it into SQL Server on a Tier-1 DevBox.
So, despite what we were told, copying a database from PPAC to a Tier-1 DevBox is still possible. It just requires a different approach and a bit more automation.
However, one important limitation remains. While we can extract a database from PPAC, there still appears to be no supported way to import a database copied from another tenant into an existing PPAC-managed D365FO environment. This is a significant restriction compared to the database export and import capabilities previously available in LCS.
Keep up to date with new articles before anyone else, subscribe to our mailing list
Table of Contents
Thank you for the request!
We will get back to you soon.
