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

I typically use service principal where I can but also use username/password.  I don't think I articulated my question well enough.  What I was hoping to do was to pass a parameter to the pipeline to determine the name of the environment so I could specify the environment name at runtime.  E.g. - "May2021DEV".  However, it appears that I need to "hardcode" a name into the service connection for this to work, and for each subsequent step to be able to do their thing.  🙂 

I have taken as a practice, using an sandbox enviromente with username and password. And after each build, do a reset of the environment using powershell.

Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Confirm:$False -Force
Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber -Confirm:$False -Force


# Here is how you can pass in credentials
$pass = ConvertTo-SecureString "$(Pass)" -AsPlainText -Force
Add-PowerAppsAccount -Username -Password $pass

$resetRequest = [pscustomobject]@{
FriendlyName = "bla"
DomainName = "bla"
Purpose = "purpose"
BaseLanguageCode = 1033
Currency = [pscustomobject]@{
Code = "USD"
Name = "USD"
Symbol = "$"
}
Templates = @('D365_CDS')
}
Reset-PowerAppEnvironment -EnvironmentName id -ResetRequestDefinition $resetRequest

Brilliant, thank you!

One more detail, I do not use the reset task that comes in Power Platform Build Tools, or the UI because there is a bug (I do not know if it persists) that installs the dynamics app in the environment.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,437)