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 / Updating environment v...
Power Apps
Unanswered

Updating environment variables via devops pipeline

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

In reference to Updating Environment Variables in Managed Solution in which @EricRegnier posts a solution to change environment variables during deployment through a devops pipeline. 
He posts the following shell script:

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"
}


However, I am having problems getting the shell script to work. 
I'm getting the following error:

Missing type name after '['.
I've replaced the GUID with the id of my environment variable and "value" with the new environment variable value.

I suppose I'm missing some important detail, but could anyone point me in the right direction?
  • capoaus75 Profile Picture
    122 on at

    Hi @Anonymous in your post you said that @EricRegnier posted a solution to change environment variables during deployment through a devops pipeline. I had a look at the link you have posted but I cannot find any reference to the shell script. I am trying to update a Solution environment variable when I deploy to a different environment and I need some guidance on how to setup the script. Any help/link that would point me in the right direction would be much appreciated. Thanks

  • capoaus75 Profile Picture
    122 on at

    I found the correct link to the Shell script Solved: How to update Environmental variables under soluti... - Power Platform Community (microsoft.com).
    @EricRegnier if you don't mind could you please elaborate a bit more how to implement the PowerShell script task in the pipeline? Let's say I have an environment variable called "SPO Site" with a value of https://mytenancy.com/DEVsite and during the deployment to TEST I would like the environment variable to be updated to https://mytenancy.com/TESTsite. Could you please point me in the right direction on how to implement this? Thank you so much.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I've given up on the idea of using PowerShell. Instead I've turned to Wael Hamze's DevOps Power Tools: Power DevOps Tools - Visual Studio Marketplace
    There is a build tool called 'Update Environment Variables', which allow you to do just what the title suggests, update environment variables. 

    Add this action after the import action and you should be all set. The build tool allows you to define environment variables and their updated values. 

  • capoaus75 Profile Picture
    122 on at

    Thank you @Anonymous looks like a very useful tool, but I am not sure our Security Team will allow us to use it. I will give it a go on my personal tenancy. Reading at this post Announcing data source environment variables | Microsoft Power Apps they mention that New build tasks will be available soon for working with connection references and environment variables. That may solve the problem.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard