Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Task 01: Configure solution-aware pipelines

Key tasks

01: Configure Power Platform environments (OPTIONAL)

In this task, you’ll run a script to recreate the Power Platform environments and import the solution. These steps are a repeat of everything accomplished in Day 1’s first exercises for setting up their environment, since the live lab was split up. YOU DO NOT NEED TO PERFORM THIS if you are following the steps on your own in one go.

  1. Sign in to the virtual machine with the following credentials (* ONLY if performing the steps in the live environment):

    Item Value
    Username @lab.VirtualMachine(Win11-Pro-Base).Username
    Password +++@lab.VirtualMachine(Win11-Pro-Base).Password+++
  2. On the VM’s taskbar, open Windows PowerShell ISE.

  3. In PowerShell ISE, select File > New.

  4. In the top pane, enter the following:

    Select Copy in the following block, then paste with Ctrl+V.

     # --- Configuration ---
     # We use the @lab variable exactly as requested for the file path
     $labInstanceId = "@lab.LabInstance.Id"
    
     # Construct the full path. (Assuming .zip based on standard lab procedures)
     $solutionPath  = "C:\LabFiles\ZavaGlobalServiceDesk_" + $labInstanceId + "_1_0_0_0.zip"
    
     # Environment Metadata
     $envs = @(
         @{ Name = "Zava Retail - Dev";  Type = "Developer" },
         @{ Name = "Zava Retail - UAT";  Type = "Developer" },
         @{ Name = "Zava Retail - Prod"; Type = "Developer" }
     )
    
     $location = "unitedstates"
     $currency = "USD"
     $language = 1033
    
     # --- Step 1: Admin Authentication (Interactive) ---
     # This handles the environment creation and governance settings
     Write-Host "Please sign in to the Power Platform Admin account..." -ForegroundColor Cyan
     Add-PowerAppsAccount -Endpoint prod
    
     # --- Step 2: Create Environments & Apply Governance ---
     # We store the created IDs to use them later
     $createdEnvIds = @{}
    
     # Define the Governance Config (Managed Environment)
     $GovernanceConfiguration = [pscustomobject]@{
         protectionLevel = "Standard"
         settings = [pscustomobject]@{
             extendedSettings = @{}
         }
     }
    
     foreach ($envDef in $envs) {
         Write-Host "--------------------------------------------------"
         Write-Host "Processing: $($envDef.Name)" -ForegroundColor Cyan
    
         # A. Create Environment
         Write-Host "Creating environment ($($envDef.Type))..."
         $newEnv = New-AdminPowerAppEnvironment `
             -DisplayName $envDef.Name `
             -LocationName $location `
             -EnvironmentSku $envDef.Type `
             -ProvisionDatabase `
             -CurrencyName $currency `
             -LanguageName $language `
             -WaitUntilFinished $true
    
         $envId = $newEnv.EnvironmentName
         $createdEnvIds[$envDef.Name] = $envId
         Write-Host "Created Environment ID: $envId" -ForegroundColor Green
    
         # B. Set as Managed Environment
         # We use a small retry loop because the environment needs a moment to be 'ready' for governance settings
         Write-Host "Enabling Managed Environment settings..."
         $retry = 0
         $success = $false
            
         do {
             try {
                 Set-AdminPowerAppEnvironmentGovernanceConfiguration `
                     -EnvironmentName $envId `
                     -UpdatedGovernanceConfiguration $GovernanceConfiguration `
                     -ErrorAction Stop
                    
                 Write-Host "Managed Environment enabled." -ForegroundColor Green
                 $success = $true
             }
             catch {
                 $retry++
                 if ($retry -lt 5) {
                     Write-Host "Waiting for provisioning to settle (Attempt $retry/5)..." -ForegroundColor Yellow
                     Start-Sleep -s 15
                 } else {
                     Write-Error "Failed to set Managed Environment after 5 attempts."
                 }
             }
         } while (-not $success -and $retry -lt 5)
     }
    
     # --- Step 3: Import Solution into DEV Only (Interactive) ---
     $devName = "Zava Retail - Dev"
     $devEnvId = $createdEnvIds[$devName]
    
     if ($devEnvId) {
         Write-Host "--------------------------------------------------"
         Write-Host "Preparing Solution Import for: $devName ($devEnvId)" -ForegroundColor Cyan
    
         # A. Get and Clean URL
         $targetEnv = Get-AdminPowerAppEnvironment -EnvironmentName $devEnvId
            
         # Logic to find the correct URL property
         if ($targetEnv.EnvironmentUrl) { $rawUrl = $targetEnv.EnvironmentUrl } 
         elseif ($targetEnv.InstanceApiUrl) { $rawUrl = $targetEnv.InstanceApiUrl } 
         else { $rawUrl = $targetEnv.Internal.properties.linkedEnvironmentMetadata.instanceApiUrl }
    
         # Clean the URL (.api.crm -> .crm)
         $cleanUrl = $rawUrl -replace "\.api\.crm", ".crm"
         Write-Host "Target URL: $cleanUrl" -ForegroundColor Cyan
    
         # B. Connect to Dataverse (Interactive)
         # We use AuthType=Office365 for interactive user login
         Write-Host "Connecting to Dataverse..."
         $connStr = "AuthType=Office365;Url=$cleanUrl;RequireNewInstance=True"
            
         try {
             $conn = Get-CrmConnection -ConnectionString $connStr -ErrorAction Stop
         }
         catch {
             Write-Error "Connection Failed: $_"
             break
         }
    
         # C. Import & Publish
         if ($conn.IsReady) {
             Write-Host "Connected. Importing: $solutionPath"
                
             try {
                 # Import
                 $importJob = Import-CrmSolution `
                     -conn $conn `
                     -SolutionFilePath $solutionPath `
                     -OverwriteUnmanagedCustomizations $true `
                     -Verbose
                    
                 Write-Host "SUCCESS: Solution imported." -ForegroundColor Green
                    
                 # Publish
                 Write-Host "Publishing customizations..."
                 Publish-CrmAllCustomization -conn $conn -Verbose
                 Write-Host "SUCCESS: All customizations published." -ForegroundColor Green
             }
             catch {
                 Write-Error "IMPORT FAILED: $_"
             }
         }
     }
     else {
         Write-Error "Could not find the Dev environment ID. Skipping import."
     }
    
  5. On the top bar, select Run Script (4i5w6k00.jpg).

    hkt7ilb7.jpg

  6. In the dialog, sign in with your lab credentials.

  7. Wait until the script completes in the bottom pane.

    ebnvpxkd.jpg

    This will take a few minutes.

  8. Close the PowerShell ISE window without saving.


02: Setup pipelines

  1. Open Edge, then go to Power Apps home page.

  2. Sign in with your lab credentials.

  3. In the dialog, select Get started.

  4. Near the upper-right corner of the page, select Environment, then select Zava Retail - Dev.

    roahebog.jpg

    eodk3mcu.jpg

    Depending on screen resolution, you may need to select the globe icon to open the Select environment pane.

    jtajbitz.jpg

  5. In the leftmost pane, select Solutions.

  6. Select Zava Global Service Desk.

    bvj22ytt.jpg

  7. In the leftmost pane, select the Pipelines (wkoz6e9m.jpg) icon.

    r9xbdwee.jpg

  8. On the top bar, select Create pipeline.

    g7p64opu.jpg

  9. In the flyout pane:

    1. Enter the following values:

      Item Value
      Name Zava Retail - ALM Pipeline
      Target environment Zava Retail - UAT

      f0e041iv.jpg

    2. At the bottom of the pane, select Save.

  10. On the top bar, select Add stage.

    21ja27qg.jpg

  11. In the flyout pane:

    1. Enter the following values:

      Item Value
      Name Zava Retail - Prod
      Target environment Zava Retail - Prod

      tzy2f6lb.jpg

    2. At the bottom of the pane, select Save.

    ob1n7ujm.jpg


03: Deploy using platform host pipelines

  1. On the Zava Retail – UAT stage, select Deploy here to initiate the solution deployment to UAT.

    grbf5arb.jpg

  2. In the flyout pane:

    If it appears, you can ignore the EnvironmentNotFound error.

    1. Under Deployment schedule, keep the default of Now.

      Selecting Later will allow you to set a time and date for the scheduled deployment.

    2. At the bottom of the pane, select Next.

      Validation may take a couple minutes.

    3. On the Summary step, observe the AI-generated Deployment notes, which contains a summary of the solution’s capabilities.

    4. At the bottom of the pane, select Deploy.

      ss84ppkk.jpg

  3. Wait until deployment completes.

    vczxngj1.jpg

    This may take 5-10 minutes.

  4. On the Zava Retail - Prod stage, select Deploy here.

    rfdq3fqa.jpg

  5. In the flyout pane:

    1. At the bottom of the pane, select Next.

    2. Select Deploy.

    Proceed to the next task. You don’t need to wait for this to complete.


Platform host pipelines are not shareable, nor can they be extended to support approvals or delegations. You can look into custom host pipelines for these options.