How to integrate existing Power Page sites into a new environment effortlessly using Command-Line Interface (CLI) – Part 2

By | December 11, 2023

Introduction:

In our previous blog, we discussed how to create and integrate Power Pages websites into a solution and how to configure them.

Now, in this blog, we will guide you through the process of transferring existing website configurations from one environment to another and exporting solutions using the Command-Line Interface (CLI).

To begin, let’s identify the existing Power Page site and its relevant details:

Site name: Site 1 – site-7ikgv

Command-Line Interface

To integrate the existing Power Page website into an alternative environment through the Command Line Interface (CLI), follow the below steps-

1. Installation and Setup:

Install Visual Studio Code and the Power Platform Tools extension. This extension allows you to execute   Power Platform CLI commands directly within the VS Code terminal.

2. Authentication:

Open the Terminal and enter the below command:

pac auth create –name [Name] -u [Dataverse URL]

Command-Line Interface

  • Name: It is an optional parameter to identify between the target and source environments.
  • -u: Specifies the URL of the environment you wish to connect to.

Upon successful authentication, a confirmation message will be displayed, indicating the connected environment’s name and profile.

Command-Line Interface
Once the authentication profile is established, the next step involves associating an index, which can be identified using the “list” command:

pac auth list

Executing the command above will display comprehensive details for all environments, as seen in the image below-

Command-Line Interface

Now, we have already created a power pages website on this https://c2etest.crm8.dynamics.com environment. The next step is to configure the same website configurations on this https://tesla.crm8.dynamics.com environment.

To transfer the identical configurations from one environment to another, you can proceed with the following steps:

Firstly, select the Power Platform CLI authentication profile linked to the source environment using the command below:

pac auth select –index [source environment index]

Command-Line InterfaceWhen executing the command below, you’ll observe the count of available Power Pages websites in the current environment:

pac paportal list

Command-Line Interface
After obtaining a list containing all WebSiteId identifiers, we can proceed to download the configuration data of the Power Pages website into a designated local directory:

pac paportal download –path [path] –webSiteId [website id]

Command-Line InterfaceWithin our site folder, a subdirectory has been generated, containing additional subfolders structured as illustrated below:

Command-Line Interface

Once the website configuration has been downloaded, if you wish to make changes to the website, you can do so by opening the downloaded subdirectory in VS Code, modifying the website’s header, and saving the edited file.

Command-Line Interface

Once the changes are completed, the next step involves connecting to the target environment where we intend to add this configuration.

Select the Power Platform CLI authentication profile connected to the target environment.

pac auth select –index [target environment index]

Command-Line Interface

Next, upload the website configuration data to the target environment.

pac paportal upload –path [path] –modelVersion 2

Command-Line Interface

Once the website is successfully uploaded, navigate to the relevant environment and access the site to view the newly created website, as shown in the below screenshot-

Command-Line Interface

Once you click on Site 1 – site-7ikgv, the power page website loads and it will be shown as below-

Command-Line InterfaceExporting Solution Using CLI:

To perform an export of the solution via the Command Line Interface (CLI), you can utilize the following command-

pac solution export –name [SolutionName] –path [path]

  • SolutionName: Represents the solution’s unique name.
  • Path: Path where the exported solution zip file is written.

Example:

pac solution export –name PowerAppSolution –path C: \Downloads

Conclusion

Using Command Line Interface (CLI) makes it easy to add Power Page sites to a new environment. CLI commands help export solutions faster, making development smoother.

Microsoft Power Platform