How to Connect Azure Web App to Azure SQL Database

后端 未结 2 997
眼角桃花
眼角桃花 2020-12-28 19:15

Azure has changed a fair bit from a year ago when I played with it.

I have a web app, and a Sql DB in my Azure resource group. I want my web app to read from my DB.

相关标签:
2条回答
  • 2020-12-28 19:56

    You don't need to store username / password details in the connection string with Azure Sql, you can add a token to the SqlConnection object. Here's a link to a site that details how to do it:

    https://www.colinsalmcorner.com/post/configuring-aad-authentication-to-azure-sql-databases

    0 讨论(0)
  • 2020-12-28 20:12

    Go to your Azure SQL Database and get a copy of the connection string. (It won't have your password, so you'll have to add that in a minute.

    Next, go to your Web App, click on the "All Settings" and under then click "Application Settings".

    Scroll down to "Connection Strings" and either create a new connection string (and paste it in from the first step) or update the existing connection string. Be sure to update the password in your connection string.

    If you create a new connection string, make sure it's the same name as that one you are referencing in your code or you will have to change your code and redeploy as that as well.

    0 讨论(0)
提交回复
热议问题