cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mikkelsen2000
Power Apps
Power Apps

Create Build Environments on demand as part of your CI/CD pipelines with the Power Platform Build Tools

With the recent GA release of the Power Platform Build Tools, we added support for creating an environment on demand and use that environment in subsequent tasks, for example to generate a build artifact and then delete the environment afterwards. 

 

  • How do you use it? When you use the 'create an environment' task in your pipeline, that environment will be used in any task that follows and the best part is you don't even have to do anything - it just works. An example of a Build pipeline is outlined below that packs a solution from source control -> runs static analysis check on the solution -> creates a new environment -> imports the solution into the newly created environment -> exports it as a managed solution (generates the build artifact) -> deletes the environment -> publishes the build Artifact

buildpipe2.png

 

Note that the URL defined in my service connection is overridden, it is the auth in the service connection that is used to ensure that the user credentials passed have sufficient privileges to create the environment. The Build Tools tasks that deals with environment actions such as create, backup, delete currently only supports username/pw auth. Support for Service Principals for those tasks is just around the corner...

 

Happy CI/CD'ing 😊 

 

 

 

 

13 REPLIES 13
v-yutliu-msft
Community Support
Community Support

Hi @Mikkelsen2000 ,

Thanks for your sharing!

I believe many other users will gain a lot from your post.

I really look forward to this new feather!  

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JaRiv
Frequent Visitor

Hello, I have made this pipeline the same way as yours, but I have a problem: When the build artifact is run, the environment creation task runs fine, but the CDS URL changed because there is a 7-day retention policy of the previously deleted instance. This then causes the deletion task to fail because it can't find the url configured in the project's connection services on DevOps. For example, the environment creation task is generated with these parameters: Name: BuildEnv and Domain: build.crm.dynamics.com. Then, when it is deleted, it is retained for 7 days. When the pipeline is executed again, it adds a 0 to the domain (build0.crm.dynamics.com) because the 7-day policy is still active, so build.crm.dynamics.com can’t be used. This then causes that it cannot be deleted because this value is not configured in the service connections.

 

Have you had the same problem?
Do you have a workaround?

damienjs
Frequent Visitor

What is the advantage of using the build environment as opposed to importing the unmanaged solution as managed with the import Build Tool? I'm trying to work out why i even need a build environment.

damienjs
Frequent Visitor

@JaRiv You could use $(Build.BuildId) in the name of the build environment that you create to ensure each time the environment name is unique and knowable. 

JaRiv
Frequent Visitor

Hello  @damienjs check this blog, https://benediktbergmann.eu/2020/02/10/cds-basic-alm-process/

and guide for Ms https://github.com/microsoft/PowerApps-Samples/tree/master/build-tools

 

This process is following the recommendation and best practice from Microsoft. Microsoft’s approach, and the approach they recommend to everyone, is the “Source-Controle centric” approach. This means that you always should store a functional version of your Solution in your Source-Controle. I do see the following main reasons for this approach:

  • Recover your development environment
  • Merge several development environments
  • See historic changes in a solution

Build Managed Solution

 

 

Sub-Process – Build Managed Solution

The Solution we stored with the first sub-process will be changed to a Managed solution in this sub-process. To do so we have to import the solution to a JIT Build (Just-In-Time Build) environment, export it as Managed and store the Zip-File as an artifact inside of DevOps.

We do need the extra JIT Build environment because this process will run independently from the first one. This could result in having a different version in our development environment than the version we would like to package. In the best case, we would create a blank new environment when starting this process. I will not go into detail in this article but will publish another one specifically on this topic.

janwillemkeizer
Frequent Visitor

Thanks for your post. 

 

When I use the 'create an environment' task I get this error:

Exception calling "AcquireToken" with "2" argument(s): "AADSTS90002: Tenant '***' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct tenant ID. Check with your subscription administrator.

 

What does this mean? Could it be that only generic service connections are supported?

 

edit: My service connection wasn't configured correctly.

Sven_Rahn
New Member

Hi @Mikkelsen2000, two questions:

1. IIUC the process of importing and exporting the solution in a "fresh" environment has the advantage of verifying, that the solution doesn't depend on other components, correct? Currently we export the solution unmanaged and managed from our DEV environment directly, without an additional build environment.
2. When importing a solution containing a Power Automate Flow, the owner of the Flow changes to the App-User which is used in the pipeline. This means, that the owner of the Flow doesn't match the owner of the connection in the PROD environment. This owner mismatch seems to cause the Flow to be deactivated. The correct owner can go into the PROD environment and activate the Flow, but that's not really automated. Is there anything wrong on my side, or are you aware of this issue?

I have been experimenting a bit trying to build some pipelines with "Just in time" environments.  What I can't figure out (and it is likely obvious) is how to establish the service connection on subsequent steps, e.g. create an environment followed by a task that imports a solution.  The docs refer to BuildTools.EnvironmentUrl but I am unsure how to use that?  Is there a place where I can see an example?  THANKS!

janwillemkeizer
Frequent Visitor

@Mikkelsen2000: Are the Tasks that deal with Environments already supported for connections with a service principal? I guess Nick and I are experiencing the same problem now. 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,716)