Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of mappen te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen om mappen te wijzigen.
Use environment variables in your data source configuration so your code app can move between environments without hardcoding dataset or table values.
Why use environment variables?
When you reference environment variables in pac code add-data-source, your app configuration stores the variable reference. The app then resolves actual values from the target environment.
This approach helps with application lifecycle management (ALM) across Dev, Test, and Prod.
Prerequisites
- A code app initialized by using pac code init
- A connection already created in Power Apps
- Environment variables created in your solution
For guidance on creating environment variables, see Use environment variables in Power Platform solutions.
Add a data source by using environment variable references
Use the environment variable schema names prefixed with @envvar: for tabular arguments such as dataset and table.
pac code add-data-source --apiid shared_sharepointonline --connectionId <your_connection_id> --dataset "@envvar:crd1b_SharepointSiteVar" --table "@envvar:crd1b_sharepointList"
In this example:
crd1b_SharepointSiteVaris the environment variable schema name for the SharePoint site (dataset)crd1b_sharepointListis the environment variable schema name for the SharePoint list (table)
Verify the result
After running the command, open power.config.json in your code app.
You should see the @envvar: references persisted in the data source configuration. This behavior means that when you move the app to another environment, it uses the values configured for those environment variables in that environment.