Skip to main content

Notifications

Power Apps - Power Apps Governance and Administ...
Suggested answer

overwrite environment variables with ALM in destination

(0) ShareShare
ReportReport
Posted on by 244
I am looking for the best practices followed for power ALM
We have unmanaged solution with automate and powerapp. About 20 env variables and 8 connection reference. 
All good. Its time to move to prod env . Reading through lot of threads it sounded like it best to do first import in prod manually . So we we created manged solution based of dev and then imported that to prod env. We were prompted to provide env variables and connection ref in prod env which is good. We set it and all good. everything worked perfectly.
 
Now  we had change in one of the flow , so we decided to redeployed through yaml pipelines. To our surprise all env varaibles were overwritten in prod. So, what went wrong is first question?
 
We came across deploymensettingconfig . So though if we used this and popukate config json with prod tenant values it will get overwirte env varaible agai  and set values from config. But wrong . Tgere was no chnage. does this mean, deployment setting config only helps during first import and ignored in subsequent deployments? Thats a second question.
 
 
Now, we had a new requirement so added new flow in dev in exisiting solution (which is already deployed in prod as managed soln). We were ready so ran piplmeline again. once deployed, new flow was part of prod managed solution however no one could see it. Because , owner of this new flow in prod was service principal. So , now we run to our environment admins which of course follows beurocracy . Question is, how do we keep owner as service account even in managed solution. (first import was done manually so that set the service account as owner automatically for all artifacts. for new artifacts we cant do it manully or is that the best practice and not use ALM if there is new artifact?)
 
(Sorry for dumping my confusion  here. I realise now this has become long thread and doubtful of getting answer 🙂)
  • Rohit4044041 Profile Picture
    Rohit4044041 244 on at
    overwrite environment variables with ALM in destination
    @swatiSTW Thank you for detailed response. Really appreciate it. Yes, We will test this in staging first. Few further comments,
     
    About #4 : Can these commands be used by developer or has to be executed by someone with System customizer role? (i am guessing later)
     
    About #5 : We did have right owner (service account) set in DEV (Source) however in destination it was replaced by service principal account.
     
    About #6 : Would it affect existing managed solution live in production if we do one off manual import of managed solution (because there is new flow added in the solution) , while other imports and future ones were carried out with pipeline 
  • Suggested answer
    SwatiSTW Profile Picture
    SwatiSTW 230 on at
    overwrite environment variables with ALM in destination
    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.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,174

Leaderboard

Featured topics