GitHub Pipeline for Deployment of PowerApps Solution

Setting up a GitHub pipeline for deploying PowerApps solutions can streamline your development process, ensuring that your applications are consistently and reliably deployed. Here’s a step-by-step guide to help you get started:

Prerequisites

  1. GitHub Account: Ensure you have a GitHub account. If not, sign up at GitHub.
  2. Power Platform Environment: You need a Power Platform environment with the necessary solutions.
  3. Service Principal: Create a service principal in Azure Active Directory for authentication.

Required information to create the flow:
  1. PowerPlatformSPN secret
  2. Client ID
  3. Tenant ID
  4. Source Environment URL
  5. Target Environment URL

To get the PowerPlatformSPN secret, Client ID and Tenant ID, you’ll need to set up a service principal in Azure Active Directory (AAD) and then create a client secret for it. Here’s a step-by-step guide:

Step 1: Register an Application in Azure AD
  1. Go to Azure Portal: Navigate to Azure Portal.
  2. App Registrations: In the left-hand menu, select Azure Active Directory > App registrations > New registration.
  3. Register Application: Provide a name for your application (e.g., PowerPlatformSPN), and select the supported account types.
    Click Register.

Step 2: Retrieve Client ID and Tenant ID
  1. Navigate to App Registration: After registering the app, you will be redirected to the application’s overview page.
  2. Client ID: The Application (client) ID is displayed on this page. Copy this value.
  3. Tenant ID: To find the Directory (tenant) ID, go to Azure Active Directory > Overview. The Tenant ID is listed under Tenant information. Copy this value.

Step 3: Configure API Permissions
  1. API Permissions: After registering the app, go to API permissions > Add a permission.
  2. Dynamics CRM: Select Dynamics CRM and choose Delegated permissions.
  3. Check the box for user_impersonation and click Add permissions.
  4. Grant Admin Consent: Click Grant admin consent for your organization.

Step 4: Create a Client Secret
  1. Certificates & Secrets: Go to Certificates & secrets > New client secret.
  2. Add Secret: Provide a description and set an expiration period. Click Add.
  3. Copy Secret: Copy the value of the client secret. This is your PowerPlatformSPN secret. (Remember to copy this value as it will not be visible again)

You can get the Source Environment URL and Target Environment URL from PowerApps. Here’s a step-by-step guide:

Step 1: Sign in to Power Apps:
  1. 1. Go to Power Apps and sign in with your credentials.

Step 2: Select the Environment:
  1. In the top-right corner, click on the environment name to open the environment picker.
  2. Select the environment you want to get the URL for (either Source or Target).

Step 3: Access Session Details:
  1. Click on the gear icon (⚙️) in the top-right corner.
  2. Select Session Details from the dropdown menu.

Step 4: Find the Environment URL:
  1. Copy the value of Instance URL.
  2. Repeat the steps to get the URL for your Target environment.

Start creating the Deployment pipeline:

Step 1: Create a GitHub Repository
  1. Create a New Repository: Navigate to GitHub and create a new repository.
    Name it appropriately, e.g., powerapps-deployment.
  2. Initialize Repository: Add a README file to initialize the repository.

Step 2: Add the Secret to GitHub
  1. GitHub Repository: Navigate to your GitHub repository.
  2. Settings: Go to Settings > Secrets > Actions.
  3. New Repository Secret: Click New repository secret and add the following:
    • Name: PowerPlatformSPN
    • Value: Paste the client secret you copied from Azure.
Step 3: Create GitHub Workflows
  1. Create a new YAML file in the .github/workflows directory, e.g., export-solutionto-prod.yml.
  2. Add the following content to export and deploy the solution and replace the values written in bold:
name: deploy-solution
on:
workflow_dispatch:
inputs:
# Change this value
solution_name:
description: 'name of the solution to worked on from Power Platform'
required: true
default: ‘Write the name of the solution’
#Do Not change these values
solution_exported_folder:
description: 'folder name for staging the exported solution *do not change*'
required: true
default: out/solutions/exported/
managed:
description: 'Export as managed solution; default is to export as unmanaged
solution'
required: false
default: 'false'
env:
#edit your values here
ENVIRONMENT_URL: ‘Source environment URL copied earlier’
TARGET_ENVIRONMENT_URL: ‘Target environment URL copied earlier’
CLIENT_ID: ‘Client ID copied earlier’
TENANT_ID: ‘Tenant ID copied earlier’
jobs:
build:
runs-on: windows-latest # alternate runner OS is: ubuntu-latest
steps:
- name: Install Power Platform Tools
uses: microsoft/powerplatform-actions/actions-install@v1
- name: Publish Solution
uses: microsoft/powerplatform-actions/publish-solution@v1
with:
environment-url: ${{env.ENVIRONMENT_URL}}
app-id: ${{env.CLIENT_ID}}
client-secret: ${{ secrets.PowerPlatformSPN }}
tenant-id: ${{env.TENANT_ID}}

- name: Export Solution
uses: microsoft/powerplatform-actions/export-solution@v1
with:
environment-url: ${{env.ENVIRONMENT_URL}}
app-id: ${{env.CLIENT_ID}}
client-secret: ${{ secrets.PowerPlatformSPN }}
tenant-id: ${{env.TENANT_ID}}
managed: ${{ github.event.inputs.managed }}
solution-name: ${{ github.event.inputs.solution_name }}
solution-output-file: ${{ github.event.inputs.solution_exported_folder}}/${{
github.event.inputs.solution_name }}.zip
- name: Import solution to prod env
uses: microsoft/powerplatform-actions/import-solution@v1
with:
environment-url: ${{env.TARGET_ENVIRONMENT_URL}}
app-id: ${{env.CLIENT_ID}}
client-secret: ${{ secrets.PowerPlatformSPN }}
tenant-id: ${{env.TENANT_ID}}
solution-file: ${{ github.event.inputs.solution_exported_folder}}/${{
github.event.inputs.solution_name }}.zip
force-overwrite: true
publish-changes: true
Step 4: Test the Workflows
  1. Push Changes: Commit and push your changes to the main branch.
  2. Monitor Actions: Navigate to the “Actions” tab in your GitHub repository to monitor the workflow runs.

Conclusion

By following these steps, you can automate the deployment of your PowerApps solutions using GitHub Actions. This setup ensures that your solutions are consistently deployed across environments, reducing manual effort and potential errors.
Share on

Leave a Reply

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