Connect to Azure SQL using Azure Active Directory from an Azure Website?

梦想的初衷 提交于 2019-12-08 01:06:46

问题


A have an Azure Website running which connects to an Azure SQL through Entity Framework 6. Everything runs and I'm using standard username/password (sql login) to connect.

Now, I would like to switch over to using AAD for authenticating to sql. I already have an AD Application set up for the website.

My question is:

  1. How do I connect with my cert or clientid/clientSecret?
  2. How do I ensure that the SqlAzureExecutionStrategy is still in function

Any guidance is much appreciated Thanks!


回答1:


There are three ways connecting to SQL database by using Azure Active Directory authentication.

  1. Connecting using integrated (Windows) authentication
  2. Connecting with an Azure AD principal name and a password
  3. Connecting with an Azure AD token

More detail about the Azure AD authentication for the Azure SQL database, you can refer here.

And if you were trying the config the connecting with access token the code sample provided by this blog is helpful. Also it is helpful to familiar with to authenticate with Azure AD with the client credential flow using the certificate from this link.

And based on my understanding, the connection string you used doesn't effect the Connection Resiliency feature which provided by the Entity Framework.




回答2:


This is what can be done in this scenario. Generally, when you first acquire a token you will get an information when the token expires. With this you should keep the time-tracking and repeat your connection code acquiring a token before the token expires.



来源:https://stackoverflow.com/questions/41501423/connect-to-azure-sql-using-azure-active-directory-from-an-azure-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!