Announcements
How to use environment variable for SQL database connection and reuse while moving the solution to production environment?
The Data Source environment variable data type only supports SAP, Dataverse, and SharePoint at this point in time. There is no way to create an environment variable that is a SQL connection,
Thanks @Pstork1
Is there anyways as a workaround or do I manually configure the SQL connection in production again?
You can't use an environment variable, but you can use a Connection Reference with a shared SQL connection in Power Apps. You can then swap the connection when you import the solution to the new environment with a different connection
Please how do I use a Connection reference
If your app is built in a solution and you add a SQL connection with an authentication like SQL authentication, so its a shared connection, then a connection reference will be created. When you import the solution to a new environment it will prompt you to create or pick a SQL connection in that environment.
How do you point the data within the app itself to use that connection rather than a direct connect to the dev database then?
For setting up environment variable for SQL database, we can use Text data type and initialise the sql server name & instance(exactly whatever we are using in SSMS to connect to the sql server). It works as expected
When you create the connection originally in the app inside the solution it will create a connection and a connection reference. then when you import it into a new environment you can change the underlying connection that the connection reference points to. Since its a connection reference you won't have to change anything in the app.
@Pstork1
And if for example you have deployed the solution in a production environment with a connection reference connected to the production SQL database, and you want to do an update with the development solution connected to the development database what is the best way to do it?
Connection References are tied to the environment. So if you update the solution in the development environment and then export it and import it to production you can update the solution without changing the underlying connection that the connection reference points to.
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.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Valantis 483
WarrenBelz 399 Most Valuable Professional
11manish 327