web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Suggested answer

Environment Variables Mapping - Azure DevOps Pipelines - Power platform

(1) ShareShare
ReportReport
Posted on by 6
Hi
 
Can someone explain how to map environment variables in solution while using Azure devOps pipeline.
This is document related to it. That I raised a question previously.
 
 
Categories:
I have the same question (0)
  • Suggested answer
    VASANTH KUMAR BALMADI Profile Picture
    266 on at
    Environment Variables Mapping - Azure DevOps Pipelines - Power platform
    Hi,
     
    Mapping environment variables in a Power Platform solution using an Azure DevOps pipeline involves defining and substituting variables during the deployment process. Here's a step-by-step explanation based on the context and the linked community forum thread:

    Overview

    Environment variables in Power Platform solutions are placeholders for values that vary across environments (e.g., development, staging, production). Using Azure DevOps, you can manage these variables dynamically and inject the appropriate values during deployment.

    Step-by-Step Process

    1. Define Environment Variables in Power Platform Solution

    • Create Variables:
      • Open your solution in the Power Platform environment.
      • Go to Environment Variables under the Solution Components.
      • Add new environment variables with a Display Name, Schema Name, and optional Default Value or Current Value.
    • Example Variable:
      • Display Name: API Endpoint
      • Schema Name: new_APIEndpoint

    2. Export the Solution

    • Export the solution from your source environment as unmanaged or managed.
    • Save the .zip file and ensure the environment variables are part of the solution.

    3. Setup Azure DevOps Pipeline

    • Create a Pipeline:
      • Use the Azure DevOps pipeline YAML or Classic Editor.
    • Install Power Platform Build Tools:
      • Add the Power Platform Build Tools extension from the Azure DevOps marketplace to your organization.

    4. Add Tasks for Deployment

    • 1. Power Platform Export Solution:

      • Task: Export Solution
      • Parameters: Export the solution from the source environment.
    • 2. Unpack Solution:

      • Task: Unpack Solution
      • Parameters: Unpack the .zip solution into source control.
    • 3. Update Environment Variables:

      • Use a script task (e.g., PowerShell) to replace placeholder values in the unpacked solution files with environment-specific values.
      • Example of environment variable mapping in YAML:
        - task: PowerShell@2
        inputs:
        targetType: 'inline'
        script: |
        Write-Host "Updating environment variables..."
        $solutionFolder = "$(Build.SourcesDirectory)/Solutions"
        $envVariableFile = "$solutionFolder/EnvironmentVariables.json"
        (Get-Content $envVariableFile) -replace '<<APIEndpoint>>', 'https://prod.api.example.com' | Set-Content $envVariableFile
    • 4. Pack Solution:

      • Task: Pack Solution
      • Parameters: Re-pack the updated solution back into a .zip.
    • 5. Import Solution:

      • Task: Import Solution
      • Parameters: Import the updated solution into the target environment.

    5. Set Up Variable Groups in Azure DevOps

    • Create Variable Groups:
      • Define environment-specific variables in Azure DevOps (e.g., Dev, Staging, Production).
    • Example Variables:
      • APIEndpoint = https://dev.api.example.com (for Dev)
      • APIEndpoint = https://prod.api.example.com (for Prod)
    • Link the variable group to the pipeline stages.

    6. Test the Pipeline

    • Trigger the pipeline and validate:
      • The appropriate environment variables are substituted.
      • The solution imports successfully with the correct values.

    7. Monitor and Debug

    • Use logs from the pipeline tasks to ensure values are correctly mapped and the solution deploys without errors.

    Key Considerations

    • Consistency: Ensure schema names for environment variables match between environments.
    • Security: Mask sensitive variables (e.g., API keys) using Azure DevOps variable secrets.
    • Pipeline Stages: Use different stages for each environment to ensure safe deployment.
    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 624 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 384 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 246

Last 30 days Overall leaderboard