PPCC25-ALM

🧪 Lab 4: Power Pages

Table of Contents

📋 Pre-requisites

  1. Complete labs 1 and 2.
  2. Install VS Code Desktop from this download link.
  3. Install Git from this download link.
  4. Following steps will work on EDM environments. (This should be enabled by default).

🗒️ Overview

In this lab, you will learn how to create a Power Pages site, add it to a solution, and set up Power Pipelines for deploying the solution to a production environment. You will also learn how to commit changes to source control using Azure DevOps and make edits to the site using VS Code with GitHub Copilot.

🎯 Tasks

🏗️ Create Power Pages site

  1. Open Power Pages Maker Studio in a new tab.

  2. You will see the first run experience. Click on Get Started button.

    Get Started

  3. Select any industry you want, for example Finance and click on Next.

    Select Industry

  4. Select any of the suggestions or you can also write your own prompt and click on Build my site.

    Build My Site

  5. Change the site name to PPCC ALM Dev and click on Next.

    Site Name

  6. If the layout looks good, click on Next.

    Site Layout

  7. Select few pages to be included in the site and click on Next.

    Select Pages

  8. Wait for the site to be created.

📦 Add site to solution

  1. Once the PPCC ALM Dev site is ready, navigate to Solutions Explorer and click on New Solution to create a new solution.

    New Solution

  2. Name the solution PPCCALMDev, select CDS Default Publisher from Publisher dropdown and click Create.

    Create New Solution

  3. Click on Objects from the left menu.

    Objects Menu

  4. Click on Add Existing button and select Site from the dropdown.

    Add Existing Site

  5. Select the site and click on Next.

  6. Select Include All Objects and click on Add.

    Include All Objects

    Note: You can also include specific objects by clicking Edit Objects and selecting them individually.

  7. Once the site and its related objects are added to the solution, you will see something like below:

    Solution with Site

🚀 Configure Power Pipelines

  1. Select the newly created solution and click on Pipelines from the left menu.

    Pipelines Menu

  2. Click on Create Pipeline button to create a new pipeline.

    Create Pipeline

  3. Name the pipeline PPCC ALM Workshop pipeline and select Prod environment as the target environment and click on Save.

    Create Pipeline

  4. Once the pipeline is created, you will see something like below:

    Pipeline Created

🚀 Deploy to Prod Environment

  1. Click on Deploy Here button to deploy the solution to Prod Environment.

    Deploy Here

  2. On the fly out panel, click on Deploy button to start the deployment.

  3. After the initial verification of deployment is complete, you will get an option to click “Deploy on the Summary Panel for Power Pipelines Deploying Solution panel.

    Deploy Solution

  4. The deployment will start. Wait for the deployment to complete.

    Deployment in Progress

  5. Once the deployment is complete, switch to Prod environment from top right corner in Power Pages Maker Studio.

    Switch Environment

🏗️ Activate Site in Prod Environment

  1. Click on Inactive Sites tab to view the list of inactive sites.

    Inactive Sites

  2. Click on Reactivate button to activate the site and then click on Done.

    Reactivate Site

  3. Optional: Preview the site by clicking on Preview button.

    Preview Site

🛠️ Committing changes to Source Control

  1. Go back to Dev environment and navigate to Solutions Explorer and select the PPCCALMDev solution.

  2. Select Source Control from the left menu.

    Source Control Menu

  3. Verify that the Changes tab has the some changes listed and click on Commit button.

    Commit Changes

  4. Enter a commit message and click on Commit button.

    Enter Commit Message

  5. After the commit is successful, click on the commit id to navigate to Azure DevOps and see the changes reflected in the repository.

    View Commit in Azure DevOps

  6. Notice that there are 3 folders created in the repository:

    1. powerpagesites - Contains the Power Pages site related files
    2. solutions - Contains the solution related files
    3. publishers - Contains the publisher information

    Repository Structure

💻 Cloning the repository locally

  1. Click on Files from the left menu in Azure DevOps to go to the repository view.

    Repository View

  2. Click on Clone button and then click on Clone in VSCode.

    Clone Button

    Clone in VSCode

  3. This will open VS Code Desktop and prompt for the local path to clone the repository.

  4. It will ask for authentication, provide your Azure DevOps credentials.

  5. If asked to automatically sign-in, select No, this app only.

    VS Code Sign-in

  6. Click on Open to open the cloned repository in VS Code.

    Cloned Repository in VS Code

💻 Editing the site in VS Code

  1. Create a new branch by clicking on Source Control icon from the left menu and then More -> Branch -> Create New Branch. Give the branch name as feature/add-welcome-message

    Create New Branch

  2. Open Home.webpage.copy.html file and use GitHub Copilot to add a welcome message to the home page. Click on Keep once the Copilot is completed making the changes.

    Edit Home Page

  3. Once the edits are done, save the file and commit and push the changes.

    Commit Changes in VS Code

  4. Now, go back to Azure DevOps repo and refresh the page. You will see a new branch created named feature/add-welcome-message. Click on Create a pull request button.

    Create Pull Request

  5. You will see the changes made in the pull request. Click on Create button to create the pull request.

  6. Click on Files tab to review the changes and then click on Complete button to complete the pull request.

    Tip: In real-world scenarios, you would typically have another team member review the pull request before completing it.

    Complete Pull Request

🛠️ Pulling changes in Solution Explorer

  1. Go back to Power Pages Maker Studio in Dev environment and navigate to Solutions Explorer.

  2. Select Source Control from the left menu and click on Check for updates button. This might take a while.

    Check for Updates

  3. Click on Pull button to pull the latest changes in the solution. This might take a while.

    Pull Changes

🛠️ Updating Environment Variables

  1. From the Active Sites tab, click on Power Pages Management for your site.

    Power Pages Management

  2. Click on Site Settings.

    Site Settings

  3. Search for the setting Authentication/Registration/LocalLoginEnabled and click on it to open.

  4. Change the value of Source to Environment Variable.

    Change Source to Environment Variable

  5. Create a new environment variable by selecting the text box and clicking on New.

    Create New Environment Variable

  6. Click on Discard Changes to open the environment variable creation panel.

  7. Create new environment variable with Schema Name and Display Name as LocalLoginEnabled and set the default value to True. Click on Save & Close.

    Create Environment Variable

  8. Now, again change the value of Source to Environment Variable and search for Local and select the newly created environment variable from the dropdown. Click on Save & Close.

    Select Environment Variable

  9. Navigate back to Power Pages Maker Studio and open Solutions Explorer and select the PPCCALMDev solution.

  10. Add the newly created environment variable to the solution by clicking on Add Existing > Environment Variable.

    Add Existing Environment Variable

  11. Select LocalLoginEnabled from the list and click on Next and then click on Add.

    Select Environment Variable

  12. The environment variable will be added to the solution.

    Environment Variable Added

🛠️ Deploy the updated solution to Prod Environment

  1. Go to Pipelines tab and click on Deploy Here button to deploy the updated solution to Prod environment.

  2. Click on Next and you’ll be asked to select a value for the environment variable. Select No and click on Next.

    Set Environment Variable Value

  3. Click on Deploy to start the deployment process and wait for the deployment to complete.

🔍 Verify changes

  1. Open the website preview in Dev environment by clicking on Preview -> Desktop.

    Preview Site in DevEnvironment

  2. Click on Sign In button to verify that the local login is enabled.

    Local Login Enabled

  3. Now, go back to Power Pages Maker Studio and switch to Prod environment from top right corner and preview the site.

  4. Click on Sign In button to verify that the local login is disabled.

    Local Login Disabled

Optional: Manage and deploy Single Page Application using Power Pages

Enable JS extensions for your environments

  1. Go to Power Platform Admin Center and select your Dev environment.

  2. Click on Settings and search for Blocked Attachments.

    Search Blocked Attachments

  3. Remove .js from the list of blocked attachments and click on Save.

    Remove .js from Blocked Attachments

  4. Repeat the same steps for Prod environment.

Deploy Single Page Application site to Power Pages

  1. Open a terminal and run git clone https://github.com/microsoft/power-pages-samples.git command to clone the Power Pages samples repo locally.

  2. Navigate to samples/bring-your-own-code/react/car-sales-website folder and open it in VS Code.

  3. Complete the steps provided in the README.md file to set up the local project and upload the website to Dev environment.

  4. Switch to Prod environment and import the solution imported in Dev environment earlier to ensure the dependencies are met.

  5. Follow the same steps as above to add the site to a solution and deploy it to Prod environment using Power Pipelines.

Optional: Supercharge your Power Pages development with Power Platform Tools VS Code Extension and PAC MCP Server

Power Platform Tools is a Visual Studio Code extension that streamlines the development and management of Power Pages sites. It offers features such as:

Install Power Platform Tools Extension

  1. Open VS Code Desktop.
  2. Click on the Extensions icon from the left menu.
  3. Search for Power Platform Tools and click on Install.

    Install Power Platform Tools Extension

  4. After installation, the extension will ask you to login. Use the same credentials you are using for Power Pages Maker Studio.

  5. You can also install it from this VS Code Marketplace.

Install PAC MCP Server

  1. Ensure you have latest .NET installed.
  2. Download PAC CLI by running below command in terminal:

     dotnet tool install --global Microsoft.PowerApps.CLI.Tool
    
  3. Run below command to get the MCP Server location:

     pac copilot mcp
    
  4. This will print out the MCP Server location. Copy the URL and add in your VS Code. It should look something like below:

     "pac-mcp": {
         "type": "stdio",
         "command": "<MCP Server Location>",
         "args": []
     }
    
  5. You can now use GitHub Copilot to manage your Power Pages sites using natural language.

    Power Pages MCP