Reputation: 11187
I'm have an Azure Web App where I've set the connection string to point to an Azure SQL DB. I'd prefer to use an Azure Active Directory username/password for authentication so I used the following connection string:
Server=tcp:mydb.database.windows.net,1433;Initial Catalog=mytable;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";
This causes my app to fail with the error:
Keyword not supported: 'authentication'
If I use the SQL Authentication (i.e. remove the Authentication="Active Directory Password"
and change User ID
and Password
to an appropriate SQL username and password), everything works as expected.
Is it possible to use Active Directory Password
with an Azure Web App connection string in order to use an AAD username/password to connect to an Azure SQL Db?
Upvotes: 0
Views: 2419
Reputation: 15658
Please change the connection string as shown below:
string ConnectionString =
@"Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Password; Initial Catalog=testdb; [email protected]; PWD=MyPassWord!";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
Another option:
string ConnectionString =
@"Data Source=n9lxnyuzhv.database.windows.net; Authentication=Active Directory Integrated; Initial Catalog=testdb;";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
Please note the text following the Authentication keyword.
Upvotes: 0