1. When deploying your solution to production for the first time, manually import it into production. During this import, set up the environment variables and connection references with production-specific values when prompted. This ensures the production environment is correctly configured.
2. For future deployments using pipelines, create a file called deploymentSettings.json. This file will store all the production-specific environment variable values. For example:
{
"environmentVariables": {
"Variable1": "ProdValue1",
"Variable2": "ProdValue2"
}
}
3. Update your YAML pipeline to reference the deploymentSettings.json file during deployment. Here’s an example configuration:
steps:
- task: PowerPlatformImportSolution@2
inputs:
authenticationType: 'ServicePrincipal'
servicePrincipalId: 'YOUR-SP-ID'
servicePrincipalKey: 'YOUR-SP-KEY'
tenantId: 'YOUR-TENANT-ID'
solutionFile: 'path-to-solution.zip'
deploymentSettingsFile: 'path-to/deploymentSettings.json'
overwriteUnmanagedCustomizations: true
The overwriteUnmanagedCustomizations: true option ensures updates are applied to existing environment variables.
4. If you add new flows to the solution and deploy them, their ownership in production will default to the service principal used in the pipeline. To fix this, use PowerShell to change ownership to a service account or the appropriate user.
First, connect to the production environment:
Connect-PowerPlatformEnvironment -EnvironmentName 'ProdEnvironmentName'
Then, retrieve the flow details:
$flow = Get-Flow -EnvironmentName 'ProdEnvironmentName' -FlowName 'NewFlowName'
Finally, set the owner:
Set-FlowOwner -EnvironmentName 'ProdEnvironmentName' -FlowId $flow.FlowId -OwnerEmail 'serviceaccount@domain.com'
5. To avoid this issue, you can set the owner of the new flow in the development environment before exporting the solution. Open the flow in Power Automate in the development environment and assign ownership to the service account.
6. If automating the owner assignment is challenging, you can manually import the solution to production for critical artifacts. During the manual import process, assign ownership to the correct service account.
7. Test the deployment process in a staging environment before applying it to production. Validate that environment variables are not overwritten, and check the ownership of new artifacts.
8. Always document the environment variables, connection references, and ownership requirements for the production environment to ensure consistent deployments.