July 2019
- Disclaimer
- Overview
- Solution architecture
- Requirements
- Exercises
- Exercise 1 - Prepare VM
- Exercise 2 - Create DevOps project
- Exercise 3 - Prepare Initial Code
- Exercise 4 - Prepare solution package
- Exercise 5 - Import solution package to Power Platform instance
- Exercise 6 - Make a change to entity via online UI
- Exercise 7 - Create Azure DevOps Pipeline
- Exercise 8 - Fixing Unit Test
- Exercise 9 - Pull request to master and deployment
- Summary
Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.
The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.
© 2019 Microsoft Corporation. All rights reserved.
Microsoft and the trademarks listed at https://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/Usage/General.aspx are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.
This lab explains ALM (Application Lifecycle Management) and CI/CD for Power Platform.
Learn how to leverage Azure DevOps Pipelines in continuous integration and continuous delivery (CI/CD) for Power Platform Apps - one of the most requested topics from our enterprise clients. This lab covers configuration migration, automatic testing, automatic build and automatic deployment.
Learn how to effectively integrate development streams, test and deploy solutions across Power Platform instances by utilizing Azure DevOps.
Common development practice is to have separate environments for Production, Staging/UAT, QA and Development. When team of developers is working on some feature (Feature 1) then feature specific instance is also needed. Developer specific instances are required too.
The challenge is how to effectively integrate all development streams and then deliver results to next instances in the chain.
Let's review how development process looks like for the team of two developers working on the same feature.
1 – Export from Dev 1 instance
2 – Back and forth development
3 – Push to Feature 1 branch
4 – Test/Package/Deploy
5 – Fetch new changes
6 – Back and forth development
7 – Push to Feature 1 branch
8 – Test/Package/Deploy
9 – Fetch new changes
...
55 – Merge to Development
56 – Test/Package/Deploy
In this Lab we implement 1-4 steps.
Lab environment:
- Azure Subscription with DevOps license
- VM with VS19 + Git + PowerShell
- 2 PowerPlatform instances
Devfor Developer's needsFeaturefeature instance that integrates work from all in team.
- Use Remote Desktop Connection app on your PC to log to lab VM, use credentials from Lab details.
- Open
Visual Studio 19from the desktop. As you load Visual Studio for the first time it asks for account details. Please use Azure credentials from Lab details.
In this exercise we prepare Azure DevOps project.
-
In browser of your choice navigate to https://dev.azure.com and log in by using your Azure credentials.
-
Click on
Sign in to Azure DevOps. -
Click
Continueon "We need a few more details" and then click onGet started with Azure DevOpspages. -
Pick a name for your private DevOps project.
-
In the rop right corner click on circle icon avatar and then click
Preview features. SwitchMulti-stage pipelinesto on. -
In the navigation on the left, click on
Reposicon and then pickFiles. -
Navigate to your
default <project name> repositorylink.Copy the code highlighted in the red box below. You will need it in the next exercise.
In this exercise we clone code from lab repository and then push it to our Azure DevOps repository.
-
In Windows Search type
Power Shellto find app, right click on it and selectRun as administrator -
In the PowerShell window we will execute commands to clone code from Lab repository to your Azure DevOps repository. Execute commands and keep PowerShell window open for later exercises.
-
cd c:\ -
git clone https://[email protected]/bocherch/PowerPlatformCICDLab/_git/PowerPlatformCICDLab -
cd .\PowerPlatformCICDLab\ -
git remote rm origin -
In this command replace URL_TO_YOUR_REPO with the url to your repository (red rectangle in the image above)
git remote add origin URL_TO_YOUR_REPO -
git push -u origin --allHere you will be asked for credentials. Use Azure credentials from Lab details.
-
In this exercise we build solution from source code, install required PowerShell module and then create solution package.
-
In Visual Studio Open solution from
C:\PowerPlatformCICDLabfolder and build it (Ctrl + Shift + B).In Visual Studio you can see that we have:
- Plugins project - C# project for custom plugins
- PluginsTest project - C# test project with unit tests for Plugins project
- SolutionPackage project - Folder structure with XML files that represents solution.
- WebResources project - Project for static web resources.
-
In PowerShell window execute these commands:
-
Set-ExecutionPolicy unrestrictedSelect Option
A -
Install-Module -Name Microsoft.Xrm.Data.PowershellSelect Option
A -
To package project into importable package run
.\PowerShell\Pack.ps1. Ignore two warnings after execution.
-
-
Your screen should look like this.
-
After the last command you have
solution.zipinC:\PowerPlatformCICDLabfolder. This is the package that was built from the source code.
In this exercise we connect to PowerPlatform Development instance and then import and publish the solution package.
-
Run
.\PowerShell\Connect.ps1in order to connect to online instance. Fill form the same way, just provide your Azure username and password and then clickLogin.In the list of available instances pick your Development instance.
-
Run
.\PowerShell\Local-2-Online.ps1. This PowerShell script will uploadsolution.zipto selected instance and then publish it. This script may run 2-4 minutes. -
Login to your PowerPlatform Development instance and validate that you have
Sample App. This is the application you've just deployed.
In this exercise we change the solution via PowerPlatform UI, then we load changes to the local repository.
-
Login to https://make.powerapps.com/ to modify solution. Make sure you pick the Development environment in the top right corner.
-
Navigate to
Solutionsand drill intoSample Solution. This is the solution we deployed from the source code. -
Do some changes withing this solution. For example you can modify Sample entity. The fast change would be to change the length of the Value field. Save Entity and then
Publish all customizationsfor the solution. -
In PowerShell window execute
git checkout -b feature/newfeature -
Run
.\PowerShell\Online-2-Local.ps1this loads solution file (zip) from online to your local folder. If it fails with message A connection to CRM is required then run.\PowerShell\Connect.ps1again and pick your Dev instance. -
Run
.\PowerShell\Extract.ps1this extracts solution into folder structure. -
If you run
git statusyou will see what was changed. Change that you did online was loaded to your PC. -
Commit changes to remote repository:
git config --global user.email "[email protected]"this and the second commands are required when you start using Gitgit config --global user.name "Your Name"git add .- stage changesgit commit -m 'Exercise 6 change'- commit changes to local repositorygit push origin feature/newfeature- push changes to remote repository
At this point we demonstrated steps 1 and 2 from this diagram.
In this exercise we create Azure DevOps Pipeline that listens to commits in branches. After commit, pipeline uses source code to build, run tests and package solution. If commit is to master branch then pipeline will also deploy package to Feature PowerPlatform instance. In order for pipeline to "know" where to deploy we use pipeline variables.
-
In Azure DevOps navigate to Pipelines Pipelines (in older environments you will see Pipelines Builds in navigation)
-
Latest Azure DevOps creates pipeline automatically as it sees
azure-pipelines.ymlis the repository. Generated name for the pipeline is<your project name> CI.If pipeline was not create then follow these steps:
- On the new screen click
New pipeline - In
Where is your code?page selectAzure Repos Gitand then onSelect a repositoryselect the name of your project. azure-pipelines.ymlis pulled from repository for your review. ClickRunto finish creating pipeline. Pipeline starts immediately onMasterbranch. Pipeline will fail on the first stage because of failing unit test. We will fix unit tests in the next exercise.
- On the new screen click
-
To finish setting up the pipeline we need to set pipeline variables.
Navigate to the Pipelines Pipelines, click on your pipeline and then click
Edit. You will see yaml source. On top right corner click on three dots menu and selectVariables. -
Please add the following variables:
eurl- use Feature url from Lab settings pageeusername- use Feature username from Lab settings pageepassword- use Feature password from Lab settings pagepackagetype- set it toUnmanaged. This setting gives you ability to deploy Unmanaged and Managed solution packages.
system.variables are added by Azure DevOps system. -
Click
Save and queueand then pick your newly created branchfeature/newfeature -
Click on Branches in left navigation and after page is loaded click on three dots for
masterbranch row. Then clickBranch policies. We are going to set a rule that pull requests to master must be followed by successful pipeline run. -
In the newly loaded window click `Add build policy.
-
In the sliding
Add build policyform select your pipeline forBuild pipelineand then click Save
In the previous exercise we created a pipeline and it detected that one of our tests is failing. We are going to fix it now. Failing demonstrates how the branch wll be automatically tested in the future.
- Open
.\PluginsTest\SamplePreCreateTests.csfile and changeAssert.False(true);toAssert.False(false);. In this lab we are not teaching how to write unit tests but we show how to build infrastructure that builds code, tests code, packages it and then deploys. - Commit change to Azure DevOps repository
git add .git commit -b 'bag fix'git push origin feature/newfeature
- After pipeline job is finished you will see that first Stage of pipeline was completed successfully. Second stage was skipped because it is a deployment stage that runs only when we push code to
masterbranch.
In this exercise we verify continues deployment. azure-pipelines.yml has steps that pipeline runs when branches are updated or when pull request is created. Let's create a pull request that takes changes from feature/newfeature to master
-
In Azure DevOps navigate to Pull Requests
Then in the top right corner click
New pull request -
Pick
feature/newfeatureinSelect a source branch. Put any title and then clickCreate -
Click
Set auto-completeto openEnable automatic completionform and then clickSet auto-complete. This step tells Azure DevOps to Complete pull request after successfully running the pipeline. -
The last step is: Azure DevOps runs pipeline on newly updated master branch. During this pipeline job second stage will be activated which deploys changes automatically to
Featurebranch.
Configured solution allows us running tests, builds, packaging jobs and deployments for all new branches in the future. This significantly saves time and prevents from human errors.
This Lab demonstrates 1-4 steps from this diagram
All further steps follow the same pattern.
For questions and comments please contact [email protected]
















