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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to update Environm...
Power Apps
Answered

How to update Environmental variables under solutions from Azure DevOps tools

(0) ShareShare
ReportReport
Posted on by 8

Hi,

 

I created environment variables of data source type to connect to SharePoint List and used it to create a Canvas APP. I wanted to push this solution to Prod by changing the Environment variables to Prod data sources. I am leveraging Power Platform Build Tools in Azure DevOps pipeline to deploy solutions into different environments but couldn't able to find a way to update those environment variables before pushing managed solution to Prod.

 

Could someone help me resolve this?

Any help is highly appreciated.

I have the same question (0)
  • Verified answer
    ChrisPiasecki Profile Picture
    6,428 Most Valuable Professional on at

    Hi @SivaGanesh,

     

    A blog announcement today mentioned that new build tasks will be available for managing environment variables in your deployment pipelines. I am not sure when this will become available, but there are also new APIs available to interact programmatically which you could use from a build script. It says the API documentation is in the process of being published so hopefully in the next couple of days this will be available.

     

    Alternatively, if you don't want to wait, the Power DevOps Tools is another popular and open source extension for Azure DevOps which has a comprehensive list of tasks available, including Update Environment Variables.

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @SivaGanesh,

    As @ChrisPiasecki mentioned, not possible up to now but coming soon. The only way is with PowerShell script task in your pipeline. Here's a sample:

    function Update-EnvVariable (
     [Guid] $EnvVariableId,
     [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $Connection
    ) {
     $updateFields = @{ }
     $updateFields.Add("value", $Value) 
     Set-CrmRecord -conn $Connection -Fields $updateFields -Id $EnvVariableId -EntityLogicalName "environmentvariablevalue"
    }

    Hope this helps!

  • SivaGanesh Profile Picture
    8 on at

    It works. Thanks a ton for the help.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @SivaGanesh could you elaborate on how you got this to work?

  • Alan Roberts Profile Picture
    31 on at

    Hi @EricRegnier, This is slightly off topic but is it possible to retrieve the Id of an Environment Variable Value from the name of the Environment Variable itself so I don't have to hard-code an ID in my pipeline?

     

    Thanks

     

    Alan

  • Alan Roberts Profile Picture
    31 on at

    Managed to get there myself in the end, at least this seems to work

    $evDefinition = Get-CrmRecords -conn $conn -EntityLogicalName environmentvariabledefinition -FilterAttribute "schemaname" -FilterOperator "eq" -FilterValue $evName
    $evValue = Get-CrmRecords -conn $conn -EntityLogicalName environmentvariablevalue -FilterAttribute environmentvariabledefinitionid -FilterOperator "eq" -FilterValue $evDefinition.CrmRecords[0].environmentvariabledefinitionid
    $newValues = @{}
    $newValues.Add("value", $Value)
    Set-CrmRecord -conn $conn -Fields $newValues -id $evValue.CrmRecords[0].environmentvariablevalueid -EntityLogicalName environmentvariablevalue
  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @DCSAlan, sorry for my late reply. Just checked your PowerShell script and confirm that how to do it,  nice one! 

  • Teju123456 Profile Picture
    4 on at

    Hi, I am working on Pipeline to build and deploy solution from one source environment to destination environment.
    I have one development environment where I am developing my power app and one other production  environment where importing solution.
    I have created environment variables for SharePoint list in solution of development environment and also created build pipeline.
    I found below environmentvariablesvalues.json file in repo.Test.png

    What should I put in  $EnvVariableId,$Connection variables?

    function Update-EnvVariable (
    [Guid] $EnvVariableId,
    [Microsoft.Xrm.Tooling.Connector.CrmServiceClient] $Connection
    ) {
    $updateFields = @{ }
    $updateFields.Add("value", $Value)
    Set-CrmRecord -conn $Connection -Fields $updateFields -Id $EnvVariableId -EntityLogicalName "environmentvariablevalue"
    }

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    The $Connection is the connection object to Dataverse. Here's an example:

    $SecurePassword = ConvertTo-SecureString 'pw123' -AsPlainText -Force
    $creds = New-Object System.Management.Automation.PSCredential ('name@email.com', $SecurePassword)
    
    $Connection = Get-CrmConnection -OnLineType OAuth -OrganizationName 'orgname' -DeploymentRegion 'Oceania' -Credential $creds

     

    $EnvVariableId is the GUID of the environment variable. You can find that in your dev environment via Advanced Find or in Maker Portal -> Dataverse -> Tables -> Envionment Varibales -> Data -> open the row and the Guid will be in the querystring
    You can find more examples here: https://github.com/ericregnier/power-platform-powershell-helpers

    Hope this helps!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 421 Most Valuable Professional

#2
11manish Profile Picture

11manish 153 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 116 Super User 2026 Season 2

Last 30 days Overall leaderboard