Using GitHub to improve the life-cycle of Apps in Power Apps || Power Platform Virtual Conference
24K views
Nov 6, 2023
Build apps in Power Apps it's very simple but delivers good solutions and manages the lifecycle in the right way has the same problems as normal "code development". In this session will see how to use GitHub to manage the entire lifecycle of the Power Apps applications from the start to the release in Production. About Speaker: Fabio Franzini is Business Applications & Office Development MVP. Senior Consultant, Software Engineer & Trainer. Conference Website: https://www.2020twenty.net/power-platform-virtual-conference/ C# Corner - Community of Software and Data Developers https://www.c-sharpcorner.com #powerplatform #virtualconference #csharpcorner
View Video Transcript
0:00
Welcome again to my session about how to use GitHub to improve the lifecycle of application in Power Apps
0:08
You already know some information about me. I'm Microsoft Business Application and Office Development MVP
0:16
In this slide, you can find some information to contact me, like email, website, Twitter, and LinkedIn
0:23
So let's start with the agenda. In this session, I want to talk about the application lifecycle management in Power Platform
0:32
And then we can go deeply how to implement the application lifecycle management using GitHub and GitHub Action
0:42
Later, I'll show you a simple demo on how to use GitHub Actions
0:49
And then at the end of the section, I'll talk about the Power Apps Language Tooling
0:56
It's a tool that are able to extrapolate the source code of PowerApps Canvas application
1:06
Later, I'll show you another demo. So let's start with application lifecycle management in Power Platform
1:13
But first, you know that the Power Platform, and specifically PowerApps, is a service that makes the possibility to every people
1:25
that have just a little bit knowledge of how to program some application
1:34
or some concept of how to call Excel function to create an application
1:42
by using a simple tool. So, a pro dev like me, or a citizen dev, or an IT admin are able to create application inside your company
1:58
But what about the application lifecycle management? So, I'm a programmer, of course, and when I build a software, I use, of course, the application lifecycle management
2:14
because I need to implement some concepts like the governance, like, of course, the development of the application
2:25
and, of course, the maintenance of the application. It's very important to implement all these topics
2:35
governance to manage the security, the user access, the change tracking, deployment
2:43
of course, all the aspects of the application development like planning, design, building, testing application
2:51
and then the maintenance. We have some tools to implement the application lifecycle management, of course
3:02
And we need to understand how to use and which tools we can use for Power Platform
3:11
In this slide, you can see a schema of all the steps
3:18
when you have to create an application. It's not important on a real coded application
3:24
or on a Power Apps application. First of all, you need to plan your application
3:30
You need to make some interviews and then take the requirement and then start to code the application
3:38
Of course, in Power Apps, Power Apps is a no-code or low-code application framework
3:47
And then the code that you can write in Power Apps, it's just a simple set of functions
3:55
that come from the same syntax of Excel. and then when you have finished to build
4:04
so to code your application, you need to usually to build your application
4:10
So if I use Visual Studio, I need to build by using Visual Studio and .NET my application
4:18
In case of Power Apps, you need just to package your application
4:23
because there are no real build process in Power Apps. package your solution, it's basically save the application in the cloud or in your desktop
4:40
In the case of the desktop, you have a file MS app
4:45
And then, of course, you need to test your application. You are able to use some automatical test tasks in Visual Studio
4:57
But in Power Apps, you need just to test your application by using the human iteration
5:05
And the Power Apps have some integrated tool to check if some functions are not configured correctly or something like that
5:19
At the end of the test, you need to release your software
5:24
There are different ways to release your software. Basically, in PowerApps, you need to push as a first version
5:32
the main version, your application, and then you are able to deploy
5:38
So, deploy in PowerApps means, like, for example, to deploy the single application or a solution
5:47
a dataverse solution, into a specific environment. environment. Later, I'll show you
5:55
And then there are different steps like operate, make some fine-tuning, make
6:01
access to some users or something like that, and monitoring your application
6:09
And then if you need to improve, again, to change your application because
6:13
the specifications are changed, you need to plan again and then code and then build and then
6:21
and then release and deploy and again monitor and start this cycle again
6:30
It's very similar. These steps are very similar from real coding application
6:38
to Power Apps. So now, how to implement application lifecycle management for Power Apps
6:50
To implement the application lifecycle management, we need to use some things, like, for example, environments
7:00
Environments are the spaces inside a specific organization. You are able to have more than one environment, of course
7:10
And we use the environment to store not only data, but solution and applications
7:20
We need solutions. Solutions are a particular way to create a package that contains application data connectors
7:35
and all things regarding the power platform. We use a solution because it's the atomic way
7:47
to move not only application, but all the dependency of an application from one environment to another one
7:59
Another thing is the SUS control, of course. The SUS controls, it's a service that are able to versioning all the files that your application was built
8:16
For example, inside a canvas application, we need a lot of files that we can store inside the source control
8:26
But in case of solution, the solution are built by using different XML files
8:33
And then we can store not only the file that contains the solution, but the source code of the solution inside an repository
8:43
In this case, we will use the GitHub repository. And then the last part, it's the automation
8:53
Automation tool and task are used to validate, import, export, pack, unpack solutions and application, of course
9:04
inside, so from our SUS control to the specific Power Apps environment and vice versa
9:13
In this schema, I want to show you just a simple schema
9:22
on how to use application lifecycle management with Power Apps. First of all, the makers needed to create or extend application
9:34
And then, by using some automations, We needed to take this application and put inside
9:43
So the application is deployed inside an environment. For example, the one environment named development environment
9:55
And then with some workflows, we are able to pull the solution from this environment
10:01
and using the PowerApps CLI, we are able to unpack the solution file
10:08
and then split all the source code that compose the solution inside all the artifacts inside the source control system
10:20
Here, we are able to change the files or work with another citizen developer
10:29
or another developer that need to change the application. And then at the end, we are able to push by pack again
10:41
from the source control, from the source file, to a real solution and push inside a test or production environment
10:51
To do that, inside GitHub, we need to use the GitHub actions
11:00
First of all, why do we need to use GitHub? Because you know that Microsoft has bought GitHub
11:12
and then I think that GitHub in the future will be the main way
11:19
main way to store the source code for Microsoft and non-Microsoft project
11:29
Recently, I don't remember, I think one year or two years ago
11:35
GitHub added new functionality as GitHub Actions. So GitHub Action help to automate tasks inside the software development lifecycle, so in application lifecycle management
11:57
All the GitHub Action are built by using a specific language named YAML
12:05
It's a human-readable markup language. and basically it's very simple to use
12:15
Later I'll show you Ana demo. And all these files, every file, it's just a workflow
12:23
that implements some, you're able to see in this image, implement different jobs
12:31
and for each job, we are able to split each job inside
12:38
on one or more than one steps. And for each step, we are able to write actions
12:49
In this case, Microsoft have recently added to the GitHub action some action to work with Power Apps, and later I'll show you
12:59
When we define this workflow, this file will save it inside an .github.workflows folder
13:10
inside your repository. And then every workflow are able to start automatically
13:19
based on a specific event. For example, when start on a pull request
13:26
request or when we release a new release of the repository or something like that
13:35
But of course, we are able to start manually this workflow. When you start this workflow
13:43
for each job, you have a specific runner. So one runner is just a virtual machine
13:52
you are able to choose from a Windows machine or Linux machine
13:58
And then inside this machine, you are able to execute every action that you have inside the job that you have to start
14:12
GitHub action for the Microsoft Power Platform. First of all, these actions are in preview
14:19
So you are able to use in production, of course, if you want, but you have to remember that these actions are in preview
14:30
At this moment, we have some few actions like the WhoAML, the import solution, the export solution, and unpack solution, the pack solution
14:43
all these functions need to authenticate of course to the specific environment to operate with this environment And at this moment Microsoft say that in the future this part will be changed
15:05
At this moment, these actions are able to authenticate to the Power Platform just using the username
15:15
and the password authentication. In the future, Microsoft extends this way to authenticate
15:23
Power Platform by using a client ID and client SQL, so an application authentication. But at this
15:29
moment, it's not possible. In my demo, I show you how to use, of course, a username and password
15:37
Basically, you need to create a specific user that has all the permission to write
15:47
to read and write inside the environments in the Power Platform. And then, of course, you need to remember to disable the multifactor authentication for this specific user
16:00
because the GitHub Actions are not able to use the multifactor authentication to authenticate to the Power Platform
16:14
So the first action, it's used to verify the service connection by connecting to the service
16:25
The second, it's a function to import a solution into a specific environment
16:33
Or another action, it's to export a solution from a SUS environment
16:40
Basically, it's a way to, again, import or export solution. Another two, it's the unpack solution and pack solution
16:53
The unpack, it's the action that are able to take a solution file
16:58
and decompose into a multiple XML, but not only XML. There are some, it depends which object are stored inside the solution, but basically are composed by XML files, JSON file, MS app files, and more
17:22
And the pack solution, it's a function that can be used to start from the source control and then create a zip file that contains the data solution that you can use to import solution in a specific target environment
17:45
So let me show a simple demo. Of course, I'll start to create an application
18:00
Basically, I create an application. I use it on a Canvas application
18:05
but it's the same if you use the model-driven app. I create the cost estimator
18:12
I create a Canvas app and then start to use the phone layout
18:18
and then I choose this cost estimator template. This is the app
18:26
I'm able to click on edit and then show you the application
18:31
This application, again, it's the standard template application. Basically, it's an application that is able to collect some information from users
18:46
and then store this information inside an Excel file. It's not a good way to save information
18:55
but just for a demo, it's okay. Save some information inside an Excel file
19:06
Okay. You remember that if you want to use... If you want to use..
19:14
So, yes, close. If you want to use the application lifecycle management
19:20
you need to create a solution. In my case, I create a solution cost estimator
19:28
and I put inside by clicking on add existing canvas app, my app previously created
19:38
Okay. Another thing is the environment, you remember. So I need to have three environments
19:50
The first environment is the dev environment. This environment is used by the citizen developer
19:56
or the pro developer to create application and then test on the developing mode the application
20:04
Another one is the environment that we use as a build environment
20:11
Later, I'll show you by using the GitHub action why we need this specific environment
20:19
And then the latest environment, it's the default environment, so the production environment
20:26
Of course, in this demo, we have three environments, but we are able to change the YAML file to implement the workflow in a different way
20:38
Basically, we need almost two environments, the dev environment and the production environment, of course
20:46
because it's not a good way to build application directly inside the production environment
20:55
Okay. Another thing is inside GitHub to have a GitHub repository. I already created this simple repository
21:08
It's an appropriate repo. And the purpose of this repo, it's, of course, to have a way to store the source file
21:22
and then manage all the history of the changes of these files
21:29
and the second purpose is to have the github actions so let me show uh
21:37
of course we start to uh to create a new uh repository it's very simple you're able to to
21:47
go to github uh go to uh the new repository put here uh the name make a public or private uh of
21:57
Of course, if this is a private repo, because if you use an app for your company
22:09
you need to store private mode your source code. You are able to choose some information like readme
22:20
In this case we don need to add a Git in your file and choose a license It a private repo and you don need to choose a license So when you click on Create Repository
22:36
you are able to have a repository like this one. OK, another thing that we can use later, it's the secrets
22:52
Basically, these settings, it's a good way to store the secret information inside a repository
23:03
For example, you remember that for use the action to interact with the Power Platform from GitHub
23:11
we need to use a username and password. It's not a good way to store password
23:18
inside the yaml file of the github action and a good way it to it's to store inside this secret
23:28
because all the variables are encrypted and it's not possible to read when you create a new secret
23:38
and then save it's not possible to by using uh api or um or the ui it's not possible to to go to
23:47
read this information the only thing that you have that you can do it's remove or update these
23:54
settings but it's not possible to read the only way to read it's to use inside the uh the github
24:02
action for example okay let me show you here inside the actions we already have two workflow
24:13
implemented by the github action the first workflow is the export and branch solution
24:24
it's implemented by this export dot yaml and of course if you go here you remember that we have
24:33
an a dot github slash workflow you are able to see all the files for the github action
24:39
So the first is the export. Basically, this is the YAML file that you can start directly
24:49
so manually, not by using an event for this example. And then inside here, we have all the jobs and then steps
25:03
that contain the action to connect and check if on a specific environment
25:13
by using this username and the password that comes from the secrets
25:17
this connection is available, and then we can use the export solution
25:24
and then use the unpack solution to store the files that are stored inside
25:32
and a solution that comes from the Power Platform inside this repo
25:38
So I go directly inside here, the export and branch solution
25:47
This is the name of the workflow. And then we can start here, run the workflow
25:55
If we click here, run workflow, after some few seconds, so you know that this is the name
26:35
the trigger manually run by my account the date of start and the status
26:44
previously it was in queue now it's in progress so if you click here
26:49
you are able to see all the jobs and inside the jobs
26:56
you are able to see all the steps and all the action that we have
27:00
inside this workflow. You remember this action needs to connect to a specific environment
27:09
And in this case, this is the URL of the dev environment
27:14
And then when the environment have exported the solution, we start to unpack solution action, okay
27:25
and then we export this cost estimator.zip solution and then a branch to create a new branch prepare it for a pull request and then make the checkout so all the steps are completed you see the green flag here and of course you are able to come back okay start to two times
27:55
the same workflow, no problem. Okay, delete. Okay. So now you are able to come back here
28:07
and then see here that we have a new branch. This is the main, the default branch
28:15
We have a new branch that have basically the name of the solution, the date
28:20
and the server time of GitHub. So if you click here, you are able to see this branch
28:33
If you click on Solution Cost Estimator, you are able to see the Canvas app
28:37
and some information like XML, Background Image, URI. We can click to see it's just a file without extension
28:52
We are not able to open this file. No, don't worry. And in this case, the msapp file
29:02
So in this case, we don't have the source code of the canvas app
29:09
but later I'll show you how to unpack this file. And, of course, you can have other files
29:20
like customization and solution.xml. Of course, you are able to go here
29:27
or by using, for example, Visual Studio Code, by clone this repo, make some changes manually
29:36
and then save again to the repo, because the next step is go to the action
29:46
and execute the release solution to prod. So let me show you this file first
29:57
The file is created. implemented again by using YAML, and it's run like the previous file on a Windows machine
30:11
It's not possible at this moment to run this action in a Linux machine
30:16
but Microsoft say that in the future, this action will be available directly inside the PowerApps CLI
30:25
and then you are able to use in a Linux machine. Why Linux or Windows
30:32
Basically, because by using Linux machine, you are able to speed up the process to execute this action
30:40
because it's more fast to use a Linux machine instead of a Windows machine
30:48
But at this moment, only Windows machine. Okay. Another thing is this workflow will be triggered automatically, workflow dispatch, on release and specific when you create a new release
31:09
Later I'll show you. This is all the steps that we have inside
31:15
So we have two jobs. The first one is convert to managed
31:20
and the second is the release to prod. Basically, we use all the action
31:27
that Microsoft have implemented for GitHub Action to interact with the Power Platform
31:32
Basically, the pack solution. In this case, we start to take the solution folder
31:39
solution cost estimator, generate a cost estimator.zip. Of course, you are able to change, it's a text file
31:48
You are able to change this folder, the name of the zip that you want to create
31:54
and all, of course, you are able to change the environment, the username, the secret, the password, and all the parameters
32:03
just by editing this file. So, first of all, pack the solution
32:09
Generate the zip solution as unmanaged solution. Then import solution as unmanaged to build environment
32:17
You remember that we have a build environment. And after that, we export the solution as managed
32:29
So again, the environment URL, it's the build environment by using the username and password
32:37
password. This is the solution, and then we save at this path the same solution, but in this case
32:49
as a managed solution. So you know that the managed solution, it's a solution that it's not possible to
32:57
change again. So it's fixed. The users are not able to modify the object that is present inside
33:07
an unmanaged solution and then upload the ready to ship solution to github artifact store
33:17
basically it's an action to store this file inside the artifact of of github the second job
33:25
it's executed again in a windows machine uh take uh the uh file from the artifact store and then import the solution to in this case the
33:42
production environment again by using a username and a secret and uh by selecting the uh the
33:51
There are some flags like force overwrite. If the solution is already present
33:58
these flags are able to overwrite the solution and then publish changes to the target environment
34:07
So to implement these two actions, basically, you need to go to this repo
34:19
repo, the Microsoft slash Power Platform minus Action minus Lab. And you are able to find the export and branch solution and the release solution to prod
34:33
It's the template of the workflow because you are able to see that we need to remove this placeholder
34:41
and put the correct environment URL, correct username. and you are able to change the solution name and the solution file name Okay So you are able to copy this one and create inside your repo So I already tested previously and I want to show you
35:03
I'm start from the dev environment. And then if I go to the production environment and I go to the solution
35:13
Okay. I'm able to see that we have the cost estimator. and if I click here, I'm able..
35:19
Okay, some problems. Don't worry. We have the same application inside the production environment
35:35
I think that this is the old version of the application. Let me click here
35:41
Okay, this is the correct application. So let me start. I want to show you, I want to remove this solution from the production
35:55
And, come on. And I want to remove, okay, this one
36:08
Basically, I want to clear the production environment. come on come on
36:26
okay let me refresh okay no problem uh okay no applications
36:36
okay and okay no problem so i want to come back to the dev
36:43
And I want to go to the applications. Remember that this app is present
36:50
It's the same if I go inside the solution. I'm able to edit this application
37:03
And I want to make just a simple change. And then I want to show you all the workflow
37:11
For example, if I go here and make the very important change, it changes the title of the first screen
37:24
I'm able to publish. Okay. And then I'm here inside the dev environment
37:33
You remember that I need to start by actions. I need to start this export and branch solution
37:41
So first of all, run the workflow, and then we have to attend some seconds to start
37:50
and about one minute and a half to execute this workflow. Later, I want to show you how to start automatically
38:02
this new workflow by creating a release of this repo. I'll take some time to start on a new instance
38:21
Okay, come on. Okay, now it's started. What we have to do at the end
38:32
Of course, we need to go to the specific branch and then create a pull request to put this branch
38:44
to the main branch because we need to create a new release of the application
38:50
After the creation of this release, we are able to start automatically the second workflow
38:57
and then deploy automatically in production this solution. So let me show if, okay, it's in an export solution
39:13
Later, we have to unpack and then branch solution. Okay. So this screen, it's very interesting
39:26
because you are able to monitor every execution of the workflow and then go to a specific step
39:35
and then check all the messages of the log. For example if you have an error you are able to go here to read the log and then understand what is the error authentication error or something like that Okay so now we can go again here
39:53
I go to the latest branch created 35 seconds ago, and then I'm able to create a pull request
40:04
I am able to write some comment, but I just create a pull request
40:11
and then I merge this pull request. So now if I go here directly on the main
40:19
I have the latest source code of the application. Now I need to go to release
40:26
and then create a new release, like put the version number eight
40:35
with title changed, and then publish this release. Now, if I go to action
40:45
I'm able to see in a couple of seconds. Come on. Okay
41:05
Come on. Let me check again. Yeah, I created the title changed
41:13
If I go here again, okay, title changed. Now it's in queue
41:21
If I click here, I'm able to see two objects. This is the two different jobs. You remember
41:28
The first job, it's the job that runs some action like Pack Solution
41:37
import solution as unmanaged, export solution as managed, and then upload to the GitHub Artifact Store
41:48
After that, you are able to come back again here, and then you can go to release to production to..
42:00
It's not possible now, I might start, to monitor the release to production
42:07
After that, we are able to see the production, the new application that has the title
42:15
the title will change. I have some topics again to show you
42:23
We contain this execution in the background and then come back to the slides
42:30
Another thing is the Power Apps language tooling. You are able to, you see that in the source code, we have a canvas up in the solution
42:42
Fabio, can you hear me? I'm really sorry to interrupt. I think there's something problem with the mic or something
42:48
It's your voice is cracking for some reason. Maybe you want to plug in and plug out once again
42:53
Let me change it. You hear me? Yeah, it's better now
43:03
Oh, OK. Sorry. OK, I repeat. Sorry. You know that in the repo, inside the solution
43:14
we have a Canvas app, but we have only the package of the application
43:22
We don't have the source code of the application. Microsoft has released this tool still
43:31
in experimental mode. It's not possible to use now in production. And this tool that available at this GitHub repo
43:43
basically it's a tool. It's a .NET tool that are able to take the Microsoft MS app
43:49
file, the Canvas file, and unpack into the source code. And again, we are able to do the same
43:58
to take the source code and then generate again the MS app to import again inside the Power Apps
44:07
So let me show you on a simple, simple demo. OK. So we have these Power Apps language tooling
44:22
You need to build first this. And then inside the bin of the bug
44:26
you have this exe file. So basically with PowerShell we needed to execute just two commands the pasopa unpack
44:45
and you need to pass the path of the file. And in this case
44:53
okay, I take this cost estimator MS app, and then if I click on Visual Studio Code
45:02
I'm able to see all the source code of the Canvas app
45:10
with all screens, with the entropy JSON file, the data sources, and another JSON file
45:19
So you can do any changes. But you remember that if you change the source code
45:28
it's possible that if you make some errors, you are not able to reimport the application inside PowerApps
45:39
And then after your changes, or just if you want to have the source code into a GitHub
45:46
or a different repository, you can use this tool. When you come back and then have again an MS app file
45:57
The only things that we have to do is to execute the same command, but with the unpack parameter
46:03
and then pass, sorry, the pack parameter by passing the path of the new file
46:12
and the path that contains the source, the folder with the source code of the canvas app
46:21
If I execute this one, I'm able to have the new application created, the new file created
46:28
and now I'm able to import inside PowerApps. So come back here
46:36
Let me show, okay. All the workflow is executed. If you go again here, title changes is executed
46:47
Now, if I go here, and then I go to the default
46:52
uh environment i don't know why we have these two application uh in my previous demo i have the same
47:01
application cost estimator without this one uh just a little i don't know error and now in production
47:11
we have the new application published automatically with the new changes in this simple demo just the
47:19
the change of the title. Okay. So it's very, very powerful. So just a recap
47:32
So you have to remember the application lifecycle management, it's very important, not only in coded application
47:39
but the same for Power Apps application, because it's very powerful to store the source code
47:48
It's very powerful to manage the ARM to deploy in a different environment automatically
47:55
You already see this one in the previous demo. And it's very important when you build an application and you have a team composed with more than one developer, of course
48:12
You can use GitHub and GitHub Action to implement this kind of the workflow
48:19
And you are able to use the Power Apps language tooling to unpack and pack the source code
48:25
of the Power Apps Canvas application. So remember that this is in a preview mode
48:32
but I think that in the next month, Microsoft released the final version of this action
48:38
and you can use without a problem in production. So inside this slide, you can find some links
48:48
basically the two links from the docs.microsoft.com that explain all the things that I covered inside this session
49:02
And the last link is the Microsoft Power Apps language tooling repo
49:08
to download the source code and then build the tool to pack and pack the source code for the Canvas application
#Software Utilities