Deploying between dev/test/prod environments

Loading

Deploying Power Pages (formerly Power Apps Portals) across Development, Test, and Production environments is essential for any enterprise-grade project. This ensures consistency, scalability, and quality across the application lifecycle. This guide walks you through how to set up and automate deployment between environments using solutions, Power Platform CLI, and ALM best practices.


Overview of Deployment Strategy

Power Pages content (web pages, web roles, web templates, etc.) is stored within Dataverse and managed using Solutions. Deployment between environments happens in two layers:

  1. Dataverse Solution Layer: Includes portal configuration data and tables
  2. File System Layer: Includes page templates, HTML, CSS, JS, images (managed via pac paportal download/upload)

Pre-requisites

  • Environments: Dev, Test, and Prod set up in Power Platform Admin Center
  • Power Platform CLI installed (pac)
  • Azure AD App Registration (Client ID, Secret, Tenant ID)
  • Portals created or provisioned in each environment
  • Portal included in a Dataverse Solution
  • Source control system (Git/GitHub/Azure Repos) is recommended

Tools Used

  • Power Platform CLI (pac)
  • PowerShell scripting (optional for automation)
  • Power Platform Admin Center
  • GitHub or Azure DevOps (for CI/CD)

Step-by-Step Deployment Flow


1. Export Portal Content from Dev

A. Export portal as a Dataverse solution

pac auth create --url https://devorg.crm.dynamics.com
pac auth select --index 0

pac solution export --name "MyPortalSolution" --path "./Solutions/MyPortalSolution.zip" --managed false

B. Export portal file system content

pac paportal download --path "./Portals/MyPortal"

This gives you a directory like:

/Portals/MyPortal/
├── webpages/
├── webtemplates/
├── content-snippets/
├── sitemap.json
└── portalsite.json

2. Commit to Source Control (optional but recommended)

Push both the solution .zip and the portal file structure to Git for version control and collaboration.


3. Import to Test Environment

A. Authenticate to Test environment

pac auth create --url https://testorg.crm.dynamics.com
pac auth select --index 0

B. Import solution

pac solution import --path "./Solutions/MyPortalSolution.zip"

C. Upload portal content

pac paportal upload --path "./Portals/MyPortal"

Optional: Reset the portal cache (after upload)

pac paportal reset

4. Validate in Test Environment

  • Browse the portal to confirm deployment
  • Validate web roles, authentication, and security permissions
  • Check Application Insights for error logs

5. Promote to Production

Repeat the same steps:

pac auth create --url https://prodorg.crm.dynamics.com
pac auth select --index 0

pac solution import --path "./Solutions/MyPortalSolution.zip"
pac paportal upload --path "./Portals/MyPortal"

⚙️ Automate Deployment with PowerShell or DevOps

Create PowerShell scripts or CI/CD pipelines in Azure DevOps to:

  • Authenticate to environments
  • Import/export solutions
  • Upload/download portal files
  • Reset portal cache

Example PowerShell snippet:

pac auth create --url $envUrl --applicationId $clientId --clientSecret $clientSecret --tenant $tenantId
pac auth select --index 0
pac solution import --path $solutionZip
pac paportal upload --path $portalPath

Security & Access

  • Use Application Users with least privilege
  • Restrict portal deployment scripts to DevOps team
  • Secure secrets using Azure Key Vault or GitHub Actions Secrets

Test Strategy During Deployment

  • Validate security roles and web page access
  • Perform performance testing in Test/Stage
  • Check for broken links, missing images
  • Confirm external user access flows (e.g., Azure AD B2C, email registration)

Tips for Smooth Deployments

Best PracticeDescription
Use managed solutions in PRODPrevents direct edits, supports stable lifecycle
Use environment variablesFor dynamic URLs, connection strings, etc.
Always reset cache after uploadEnsures updated content is reflected
Enable Application InsightsFor portal diagnostics and performance
Tag deploymentsAdd metadata for each deployment in Git or DevOps logs

Leave a Reply

Your email address will not be published. Required fields are marked *