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 / Solutions and environm...
Power Apps
Suggested Answer

Solutions and environment variable issues

(1) ShareShare
ReportReport
Posted on by 59

Hi,

 

We have a canvas app that uses SharePoint as the backend that has a dev, staging and production version across three environments. We have a single SharePoint site that each environment saves to and have been using a column to filter out data between each environments app/flows.

 

As part of an upgrade to our app we have created three separate SharePoint sites so each environment will connect to its own. All data sources in the app and all SharePoint connections in our flow point to environment variables. The intention being that when we make a change and push it through our environment's we only have to amend each environments, environment variables and everything is good to go.

 

In the future we plan to add several additional production versions of the app with their own SharePoint sites to cater to different teams.

 

Unfortunately we have been running into several issues, while I have most things worked out, I wouldn't mind some feedback on whether this is the correct approach and am just posting this for other users. We do not want to end up in a situation where each change we make to the app in dev requires extensive modifications per environment to get up and running.

 

Our setup

Environment Variables

One master variable to store that environments related SharePoint site. A variable per SharePoint list that uses the master variable for the site and points to the appropriate list under that site

 

Canvas app

Each data source is uses that master variable, then points to the related list environment variable.

 

Flows

Each SharePoint action uses the master variable, then the appropriate list environment variable, no SharePoint actions are directly pointed to SharePoint.

 

What we expected

When exporting the solution from dev as a managed solution, we import it into staging or prod and that it prompts or allows us to update the environment variables. Once all environment variables point to the site related to that environment. The app and flows work without issue.

 

What's happening

Environment variables

When importing we were not prompted, attempted removing the current value of each environment variable and re-importing with no luck. We could not amend the environment variables within the solution as it was managed. 

Fix -

  • Going to the default solution and amending them there - worked after lots of trial and error, ended up having to delete the solution from staging and re-importing it then modifying the environment variables, but that may be due to all the messing around I was doing. Hopefully modifying the default solution in the future just works.


Canvas app

After amending the environment variables then playing the canvas app only some data sources were pointing to the staging SharePoint site, with others pointing to the dev one, despite them using an environment variable that was pointing to staging.

 

To further test, back in dev I removed all data sources, re-added them via the site environment variable and re-exported then app and imported into staging with the same result.

 

Fix - Once in staging remove all data sources from the app and re-add them via the master site environment variable.

 

Flow

One of our PowerApps triggered flows was erroring, the 1st action that connects to SharePoint using the site environment variable and list environment variable errored, in the error log it was pointing to the dev site and not staging which the environment variable has been set to.

Fix - Started randomly working after about an hour...

 

Categories:
I have the same question (0)
  • hemrhk Profile Picture
    361 on at

    @BenAu 

    In Canvas App While connecting the datasources it should be loaded via Environment Variables otherwise it will be still pointing to the existing datasource.

    Before exporting remove the values in the environment variable then only it will prompt to enter the datasources while importing.

     

    Checkout this post to setup the solution,

    https://365stack.in/index.php/2022/01/03/how-to-get-started-with-power-platform-solutions-canvas-apps/ 

     

    ------------------------------------------------------------------------------------------------- 

    If it solved your problem give a kudo and accept it as a solution. 

    Follow and Subscribe 365 Stack for more updates. 

  • BenAu Profile Picture
    59 on at

    Data sources within the canvas app are pointing to environment variables. After exporting/importing even though every data source pointed to an environment variable that was pointing to our staging data, some were still picking up dev data.

     

    When i removed all data sources in the staging app and re-added, I added them using the exact same environment variables as dev and it worked. I guess I will have to monitor to see if future changes still cause have this issue.

     

    Also tried clearing the values before exporting, it did not trigger a prompt to enter data source when importing.

     

    The feature seems buggy to me.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Seconding BenAu--I'm having exactly the same issue with Canvas apps+SharePoint+SharePoint data source environment variables. When I migrate apps using SharePoint data sources I have to edit the app, manually remove all the environment variable references, then re-add them. And since this also adds an unmanaged layer to the testing/production managed solutions, I have to first remove that for every deploy past the first. Would love some guidance here!

  • BenAu Profile Picture
    59 on at

    We were unable to solve this, and have settled in with editing the apps, removing sources and re-adding. Then removing the unmanaged layer as you have been for each update.


    Its annoying as some SharePoint data sources appear to properly connect to the lists the environment variables point to while others do not until being removed. So its like half working 😞

     

    On top of the fact there appears to be no way to make PowerApps prompt to fill the environment variables in when importing so we have to do a workaround. 

  • Arkay71 Profile Picture
    19 on at

    We had exactly the same problem but did manage to solve it (we think) like this:

     

    1. In your DEV environment, remove the current value of the SharePoint Site and List connections so the values are both blank. I did this in the Solution itself.

    2. Now open the PowerApp in DEV and remove, then re-add the datasource using the now empty environment variable - It should add OK but you'll get lots of red 'x' on the screen as the connections are empty.  Save and publish the app.

    3. In your DEV solution, publish customizations and export the solution (we used Managed as we're going to PRO)

    4. Import the solution into your PRO, or UAT, environment and provide the PRO values for your SharePoint Site and List.

     

    You should now have your published PRO solution pointing to your PRO SP datasource without having to add an unmanaged layer...  I'm continuing to test but this seems to be working OK.  Feedback welcome (and Microsoft - PLEASE make this easier!!!)

  • m3ngi3 Profile Picture
    725 on at

    Another latest update (also see Solved: Updating Environment Variables in Managed Solution - Power Platform Community (microsoft.com)😞 you ALSO need to remove the Default Value from the Environment Variables to get the prompt during the Solution Import. In my multiple tests of a FIRST solution import, this gave me the modern wizard prompt to update the variables right after the step to update the Connection References with Connections.

  • CH-24102312-0 Profile Picture
    on at

    I've been looking at this for the past few days and I've noticed that changing the value of the SharePoint environment variable in the recipient environment's Default solution doesn't work immediately, but does 'kick in' after around 60 to 70 minutes. In the testing I've done this was the case on every occasion and the apps and flows then worked as expected

     

    I tried with just a current value ,just a default value and both current and default values and all eventually worked as they should. The delay isn't ideal, but waiting an hour or so when transitioning to a new environment is do-able

     

    More testing tomorrow 

  • Reinerknudsen87 Profile Picture
    59 on at

    I have exactly the same issues. And yes, I remove the values from the variables before export. Sometimes I get prompted, sometimes I don't. I also noticed that removing and re-adding the variable from/to the app works. But seriously: That can't be the way!

    In addition we face the issue that once we upgrade a solution the referring environment variables in the target environment are suddenly empty and must be set before removing and re-adding them to the app. This feature is rubbish.

  • KarolZareba1 Profile Picture
    16 on at

    And if I understand correctly, after such an operation, I have to go back to the solution on the DEV and from the soloution to update anew each Sharepoint storage variable, edit the application, remove the connections and add them anew in the reference to the environment variables? 😡

  • KarolZareba1 Profile Picture
    16 on at

    Exactly it sucks! I never know if after updating the app to PRO it will work properly saving the data in the right place!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,041

#2
11manish Profile Picture

11manish 676

#3
Valantis Profile Picture

Valantis 655

Last 30 days Overall leaderboard