web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Deploying Environment ...
Power Pages
Answered

Deploying Environment Variables in a managed solution using Power Platform Pipeline

(1) ShareShare
ReportReport
Posted on by 62
I've been struggling with this issue for some time now. Environment Variables are generally a good idea to create flexible solutions, but boy, are they tricky when used in a managed solution, deployed by a Power Platform Pipeline. So far the ONLY way that works for me is this:
 
  1. Create EV in solution on the DEV environment
  2. Set "Current Value" to a value appropriate for the DEV environment
  3. Before EACH (!!!) deployment, REMOVE the value of each EV. (I forgot this today and now I'm in trouble, see below...)
  4. After deleting the values, deploy the solution to the managed target environment
  5. During deployment, you'll be asked to specify the value (appropriate to the target environment)
  6. Complete deployment afterwards
  7. Go to 2. (Set "Current Value"...) and continue with the next development iteration
This works. But constantly SETTING the values and then REMOVING them again before deploying is cumbersome and dangerous. And wouldn't you know it, today I forgot to remove the values and deployed the solution as is. That worked, but of course the EV values were incorrect. No big deal, I thought, I'll simply re-deploy the solution with the usual step of removing the values. But nope, whenever I try to deploy the solution now, I get this weird error "Cannot insert duplicate key in object 'dbo.EnvironmentVariableValueBase'". I tried different steps, removing the EVs from the solution - deployment fails "Object reference not set to an instance of an object"). Setting the existing EV values on the target environment manually (using the trick with the Default solution, which lets me change EVs outside of the managed solution) then try re-deploying. But that didn't help either.

I'm stuck! It seems having forgot to remove the values killed my chances of re-deploying the solution. Luckily, the target environment is only a TEST environment and scrapping the whole solution will not be a disaster - but soon we will deploy to a production environment and I'm almost certain, that one day I will forget to remove the EV variables again during a rushed deployment and may become stuck again. Scrapping the whole solution won't be possible then. There HAS to be an easier and less dangerous way of using EVs in managed solutions!

A blog post suggested that EVs shouldn't be part of a managed solution at all, instead the should be in their own unmanaged solution and deployed separately to the target environment. I'll experiment with the idea for sure, but I'm also a little doubtful it will work...

Is there a rock-solid Best Practice for this? 
Categories:
I have the same question (0)
  • Flury Profile Picture
    62 on at
    I should also mention: I'm aware that below the Current value setting, there is a slider "Export Value". However, probably due to a current bug, this slider can't be changed! I will jump back to "export" when saving the EV setting. I can't see anyone mentioning this yet, so it must be a recent bug...

    EDIT: A MS support rep is helping me look into this. The problem with the slider seems to be specific to my solution. Even creating a new temporary solution on the same environment didn't have the same issue. So if the slider "Export Value" is by default in the "No" position, this is good news of course. It means, I should be able to simply leave my DEV EV current values in place and still get asked to provide new values during the deployment - without manually removing the values each time. Fingers crossed.
  • Verified answer
    Flury Profile Picture
    62 on at
    Resolution to this bug according to a MS support rep: 

    When a solution is marked as "preferred solution", apparently this bug sometimes appears: Your environment variables default to "Yes" and can't be turned off either. However, on the same environment, if you quickly create a temporary second solution and mark it as "preferred solution", then you should be able to change the slider to "No" and it will also stay "No" once you mark the solution again as preferred solution. 
     
  • Kowles Profile Picture
    9 on at
    I have the same problem with the "export value" slider. 9 months later than your post. Did you get a resolution from the MS rep?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 78 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 75

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard