Use data source environment variables in canvas apps
In this article, you'll learn about using data source environment variables in canvas apps. You can either use pre-existing data source environment variables, or create data source environment variables automatically when connecting to data.
Use pre-existing data source environment variables
Environment variables can be reused across other apps and even different types of resources like cloud flows. You might wish to first create them within your solution and later use them while authoring canvas apps and cloud flows.
- Follow the steps to create an environment variable in a solution.
- Edit or create a canvas app from your solution.
- Add a new data source for SharePoint online.
- Select the Advanced tab. You'll see a filtered list of environment variables that you have access to and that match the parameter being set. For example, when you select the SharePoint site, you'll see a list of all data source environment variables with Connector as SharePoint and Parameter type as Site. The same is true when selecting SharePoint lists for a given site.
- Select the desired environment variable(s), and then select Connect.
Important
- If an environment variable from a different solution is selected, a dependency will exist on the solution containing the environment variable. Therefore, be sure to either:
- Add the environment variable to your current solution prior to exporting.
- Ensure the solution containing the environment variable is imported to the destination environment before your current solution is imported.
Automatically create data source environment variables when connecting to data
This option provides simplicity and ensures environment variables will always be used for data sources, such as SharePoint Online. However, some customers prefer to provide their own schema names and therefore should create them from solutions.
Note
Pre-existing canvas apps will not automatically use data source environment variables. Remove the data source from the app and add them back using the above steps to upgrade these apps to use environment variables.
Edit or create a canvas app from your solution.
Select Settings > General and enable the setting to Automatically create environment variables when adding data sources.
Add a New data source for SharePoint online.
Select a SharePoint site, one or more lists, and then Connect.
Note
To prevent creation of duplicate environment variables, you'll be prompted to use the existing environment variable when duplicates are identified. You can clear the option to use the existing environment variable if creation of a duplicate is desired.
Select Save.
See also
Create canvas app from scratch using Dataverse.
Use environment variables in Power Automate solution cloud flows
Environment variables overview