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:
Required information to create the flow:
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
Step 2: Retrieve Client ID and Tenant ID
Step 3: Configure API Permissions
Step 4: Create a Client Secret
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:
Step 2: Select the Environment:
Step 3: Access Session Details:
Step 4: Find the Environment URL:
Step 2: Add the Secret to GitHub
Prerequisites
- GitHub Account: Ensure you have a GitHub account. If not, sign up at GitHub.
- Power Platform Environment: You need a Power Platform environment with the necessary solutions.
- Service Principal: Create a service principal in Azure Active Directory for authentication.
Required information to create the flow:
- PowerPlatformSPN secret
- Client ID
- Tenant ID
- Source Environment URL
- 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
- Go to Azure Portal: Navigate to Azure Portal.
- App Registrations: In the left-hand menu, select Azure Active Directory > App registrations > New registration.
- 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
- Navigate to App Registration: After registering the app, you will be redirected to the application’s overview page.
- Client ID: The Application (client) ID is displayed on this page. Copy this value.
- 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
- API Permissions: After registering the app, go to API permissions > Add a permission.
- Dynamics CRM: Select Dynamics CRM and choose Delegated permissions. Check the box for user_impersonation and click Add permissions.
- Grant Admin Consent: Click Grant admin consent for your organization.
Step 4: Create a Client Secret
- Certificates & Secrets: Go to Certificates & secrets > New client secret.
- Add Secret: Provide a description and set an expiration period. Click Add.
- 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. Go to Power Apps and sign in with your credentials.
Step 2: Select the Environment:
- In the top-right corner, click on the environment name to open the environment picker.
- Select the environment you want to get the URL for (either Source or Target).
Step 3: Access Session Details:
- Click on the gear icon (⚙️) in the top-right corner.
- Select Session Details from the dropdown menu.
Step 4: Find the Environment URL:
- Copy the value of Instance URL.
- Repeat the steps to get the URL for your Target environment.
Start creating the Deployment pipeline:
Step 1: Create a GitHub Repository- Create a New Repository: Navigate to GitHub and create a new repository.
Name it appropriately, e.g., powerapps-deployment. - Initialize Repository: Add a README file to initialize the repository.
Step 2: Add the Secret to GitHub
- GitHub Repository: Navigate to your GitHub repository.
- Settings: Go to Settings > Secrets > Actions.
- New Repository Secret: Click New repository secret and add the following:
- Name: PowerPlatformSPN
- Value: Paste the client secret you copied from Azure.
- Create a new YAML file in the .github/workflows directory, e.g., export-solutionto-prod.yml.
- Add the following content to export and deploy the solution and replace the values written in bold:
name: deploy-solutionStep 4: Test the Workflows
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
- Push Changes: Commit and push your changes to the main branch.
- Monitor Actions: Navigate to the “Actions” tab in your GitHub repository to monitor the workflow runs.