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.
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!
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.
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"
}
Hi @DCSAlan, sorry for my late reply. Just checked your PowerShell script and confirm that how to do it, nice one!
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
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
@SivaGanesh could you elaborate on how you got this to work?
It works. Thanks a ton for the help.
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!
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.
Michael E. Gernaey
11
Super User 2025 Season 1
stampcoin
9
bscarlavai33
5
Super User 2025 Season 1