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 / Environment variable f...
Power Apps
Answered

Environment variable for SQL database connection

(0) ShareShare
ReportReport
Posted on by 7

How to use environment variable for SQL database connection and reuse while moving the solution to production environment?

Categories:
I have the same question (0)
  • Verified answer
    Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    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,

  • Kavya11 Profile Picture
    7 on at

    Thanks @Pstork1 

     

    Is there anyways as a workaround or do I manually configure the SQL connection in production again?

  • Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    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

  • ElvisEyobor Profile Picture
    7 on at

    Please how do I use a Connection reference

  • Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    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.

  • Nicci Profile Picture
    194 on at

    How do you point the data within the app itself to use that connection rather than a direct connect to the dev database then?

  • Majeti_Lakshmi Profile Picture
    6 on at

    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

  • Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    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.

  • gikido Profile Picture
    1,032 on at

    @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?

  • Pstork1 Profile Picture
    69,543 Most Valuable Professional on at

    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.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 431

#2
WarrenBelz Profile Picture

WarrenBelz 360 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 280 Super User 2026 Season 1

Last 30 days Overall leaderboard