Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Governance and Administ...
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.

Categories:
  • EricRegnier Profile Picture
    8,714 Most Valuable Professional on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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!

  • Teju123456 Profile Picture
    4 on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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,714 Most Valuable Professional on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

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

  • Alan Roberts Profile Picture
    31 on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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
  • Alan Roberts Profile Picture
    31 on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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

  • Community Power Platform Member Profile Picture
    on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

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

  • SivaGanesh Profile Picture
    8 on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    It works. Thanks a ton for the help.

  • Verified answer
    EricRegnier Profile Picture
    8,714 Most Valuable Professional on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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!

  • Verified answer
    ChrisPiasecki Profile Picture
    6,389 Most Valuable Professional on at
    Re: How to update Environmental variables under solutions from Azure DevOps tools

    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.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Governance and Administering

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 11 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 9

#3
bscarlavai33 Profile Picture

bscarlavai33 5 Super User 2025 Season 1

Overall leaderboard

Featured topics