The previous challenge was about utilizing pro dev features to improve your low-code approach. This challenge has the same objective. In this challenge you will:
🎯 learn about Application Lifecycle Management
🎯 build a simple development pipeline (dev/prod)
🎯 automate solution deployment using GitHub Actions
🎯 (hopefully) be activated to think about when to build a pipeline
For those who have not tried challenge 002 yet, I can highly recommend taking that one first.
🤓 Why Application Lifecycle Management (ALM)
Many of you are excited about the Power Platform because it enables you to build tailor-made solutions without a major knowledge investment. The fact that I make these challenges shows I am a big advocate of the Power Platform myself. However, building a solution is just part of ALM. You might have experienced that once you’ve built a solution, you want to have additional features. As you probably know, you can adjust your app and save it until development is finished and publish the app which makes the newly added features available for the end users.
For some solutions, this functionality is sufficient. But what about more critical applications? You might have accidentally added some features that don’t work as expected, or even worse, broke some features from the previously published version. For these scenarios, you can set up a development pipeline.
The concept of the pipeline is that the solution is developed in a dev environment, stakeholders will test it in the test environment and end users can access it in the production environment. This way you will significantly decrease the number of errors in the solution used by end users. If you really want to dive into environments, when to use what, etc. the Microsoft documentation on establishing an environment strategy is something you should check out.
So now you are an ALM expert. Let’s automate this process to become 🔥ALM🔥level🔥9000🔥.
🛵 Challenge instructions
Build a pipeline
The first step in this challenge is building a pipeline. We will use the default environment as the production environment, so you will need to make a development environment. As a developer, you can request one here. For this challenge, only dev and prod will be used, but the pipeline could have as many environments as needed (e.g. dev/test/prod).
Build a solution in your dev environment
Due to the focus of this challenge on deployment automation, we will build a super simple solution.
Create a new solution called Challenge 003
Add a table called Challenges
Add a canvas app
Add a vertical gallery to your app
Save you app
That’s it for now. 🥳 At this moment, the app will only show the challenges, but does not have add/edit/delete functionality. That will be our additional feature.
Register your app in Azure AD
To automate the deployment 🚀, your script should have access to your environments. That’s what this and the following section of this challenge will guide you through.
Go to Azure
Select Azure Active Directory
Select App registrations
Create a new registration called Challenge 003 and select Accounts in any organizational directory (Any Azure AD directory - Multitenant)
After creation, note the Directory (tenant) ID and Application (client) ID.
Select the Manifest tab, in the manifest editor, set the allowPublicClient property to true and click on Save.
Select the API permissions tab and add a permission. Search and choose Dataverse on the APIs my organization uses tab, select user_impersonation and add the permission.
Do the same for PowerApps Service - User and PowerApps-Advisor - Analysis.All. Make sure to select the version where no admin consent is required.
Select 🔑 Certificates & secrets tab and add a secret. Make sure to note the secret value. It will only be shown once.
Add Application user
Go to the Power Platform admin center
Select the Development environment and click on Settings
Under Users + Permissions, select Application users
Select New app user
Add a new app user and select the just created Azure AD app
Select a business unit. in your dev tenant there probably is just one with org in the name.
For the security role, select System administrator.
Do the same for your production environment
Export Solution from dev using GitHub Actions
Because you already conducted challenge 002, you should already have a GitHub account. If not, check how to get one there.
Create a new repo
Go to the settings of the repo
Under Secrets, add an action secret named PowerPlatformSPN. Enter the secret value you noted during the registration of your Azure AD app in the value box.
Now go to the Actions tab and create a set up a workflow yourself.
Replace the default code with the lovely script that Microsoft created for us. you can find it HERE.
Replace the three values listed under env. Environment URL is the dev environment from which you want to export, thus the developer environment. The URL can be found in the Power Platform admin center. Make sure you include https:// to the URL. Client ID and Tenant ID are values you’ve noted while registering your app in Azure AD.
Rename the file to export-and-branch-solution.yml and commit the file to your GitHub repo.
Well done! the first action should work right now. Let’s test if it works and what it does.
Go to the actions tab. Now you should see there is a workflow called export-and-branch-solution listed
Select run workflow
Make sure you enter the correct name of your solution in your dev environment. If you followed this challenge in detail it will be Challenge003.
Run workflow 🚀
When the workflow is running you can click on the workflow to see what it is doing. It is like a mix of command prompt and watching a Power Automate flow executing. You can see the steps and if there is an error, it will show you the problem. If an error occurs, this is helpful information for debugging. If this is not sufficient information, please use the comments section below.
If there is no error or you managed to debug it, you did a pretty amazing job. If you navigate to the code tab, you can see a new branch has been added. Branching is a Git way of collaboration and version control, which we will not dive into for now. The only thing you must know is that you have to make this export available in our master branch.
Navigate to the Pull requests tab
Compare the master branch with the newly created branch. Notice that it is able to merge the to branches.
Select Create pull request. From now on you will call it a PR to show you are the real deal. A pull request is a request a contributor makes to the repo owner to merge the branches.
Because in this case you are the contributor and repo owner you can directly merge the branches.
After merging you can delete the branch.
Import Solution in prod using GitHub Actions
Now that we have the dev solution in our source control, the next step is to import it in our production environment as a managed solution. That is what we will do in this part of the challenge.
Go to the action tab and create a new workflow
Again, replace the default code. Microsoft also has this part covered. you can copy the code from here.
Replace the values under the env section in the code. Don’t forget the https:// part 😉.
Rename the file to release-solution-to-prod.yml and commit the file to your GitHub repo.
You know the drill of running it now, so go ahead. Just check your prod environment to see there is no solution called Challenge 003 at this moment. That will change after running the workflow. After the workflow ran successfully, the solution should be listed in the production environment. If you made it this far that’s quite impressive. all kudo’s to you pal! 👏👏👏
Add features to your solution and publish to prod
The pipeline is now fully operational. You can further develop the solution in the development environment. Based on the solution we created at the beginning you could think of add/edit/delete records as additional feature to your solution. Build whatever suits you. Once you have added these new features in the development environment, use the GitHub Actions to get the new version to the production environment. 🙌
🎒 Key takeaways
👉🏻 For solutions that are critical, you want to build a development pipeline
👉🏻 When more critical applications are developed using Power Platform, an environment strategy is highly recommended
👉🏻 You can automate deployment using GitHub Actions