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

adal azure-active-directory azure-sql-database azure-web-sites entity-framework-6


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/6/2017 8:01:11 AM

Accepted Answer

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.

1/9/2017 8:09:37 AM

Popular Answer

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.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow