Import and Export Demo data for Dynamics 365 using Azure DevOps
Have you ever wished for a simple way to deploy the data you are testing from one environment to another? Or just a simple way for resetting the data back to “original”.
This blog post will help you to move both demonstration data and configuration data.
In this blog post, I will demonstrate how you could export and import your own set of demo data for Dynamics 365 using Azure DevOps Pipelines.
I will define a scheme using Configuration Migration Tool and then use this to export data from a development environment and commit XML with data to Azure Repo. After the data is saved I will deploy the data in the environments of our choice.
The benefits of this solution will be to just assign the newly created records to an owner team and just run the pipeline which will then export all records assigned to a certain team.
The cons of this solution, will be that you need to define a new schema when a new field is created (and you want this value to other environments)
1. Make sure you got the same owner team in all environments.
I usually start off by creating an owner team in the development environment and then migrate it over to the other environments.
It is essential that the ownership team has the same GUID in all environments.
After you get the same owner team in preferred environments, update the security role of the team. (This is to allow the team to own certain records you want for your demo).
Preferred tools: XRM toolbox or Configuration Migration Tool.
2. Create a record in development and assign it to the owner you created
We will create an account for this purpose and assign it to the owner team.
3. Install Configuration Migration Tool
This is to create a schema to define which records we want to export, in this schema we will define records owned by our owner team “Demo Team”.
If you are not certain how to install and run Configuration Migration Tool, please check out this blog post.
https://learn.microsoft.com/en-us/power-apps/developer/data-platform/download-tools-nuget
4. Create a schema for getting the records we want
Click “Continue” and log in to your organization. After that, you will need to choose the environment you want to export the data.
Then define which entity (table) you want to export, and then select the fields from the entity (table).
To maintain the same GUID of the account, we will need always to include the “accountID” which is the primary key.
After choosing the fields, click at the top under “Tools” -> “Configure Import Settings” and then “Use FetchXML to filter records”.
This is to make the schema only export contacts that are owned by the “Demo Team” we created.
When you got the filter correct, click “Save” and “Save and Export”.
Choose then where to store the data files (There will be two files)
And click “Export Data”.
Hopefully, if you got the filters correct you will see something similar to this:
When you got the files stored on your computer, there should be a .zip file containing these files:
The data.xml will contain the record(s) you exported, while the data_schema.xml contains the schema to export the record(s).
5. Create an Azure DevOps Pipeline to Export Data from Development Environment and publish it to the repo
Now that we got the schema for defining which records we want to export, we will upload the data_schema.xml to Azure Repo. This is to make it available for the pipeline to use when exporting from an environment.
When you got the data_schema.xml in Azure Repo, we can go on to create our pipeline.
We will create a pipeline using the classic editor, with the following tools and settings:
This pipeline will successfully export the data and store it inside data/data.zip. After the Power Platform Export Data task is successful, it is necessary to commit these changes to the repo using a command line script.
Now, let’s navigate to “Repo” and see if our file got updated:
6. Create a release pipeline to install the demo data in other environments
Start off by creating a new release, with two stages (Depending on how many environments you want to push the data to).
Each of the stages will contain these settings and tools: