Azure database connection string

If we want to connect to your local database server using windows security;

{
  "ConnectionStrings": {
    "MyDbConnection": "Server=(local);Database=MyDatabase;Trusted_Connection=True;MultipleActiveResultSets=true"
}

If we want to connect to your remote database server using windows security;

{
  "ConnectionStrings": {
    "MyDbConnection": "Server=1.1.1.1;Database=MyDatabase;Trusted_Connection=True;MultipleActiveResultSets=true"
}

If we want to connect to Azure SQL database server using SQL Server security;

{
  "ConnectionStrings": {
    "MyDbConnection": "Data Source=databaseserver.database.windows.net;Initial Catalog=MyDatabase;User ID=dbuser;Password=dbuserpassword;Connect Timeout=30;Encrypt=True;MultipleActiveResultSets=true;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}

if we want to connect to Azure SQL database using Azure AD identity

Server=tcp:myserver.database.windows.net,1433;Authentication=Active Directory Integrated;Database=mydatabase;

If we want to connect to Azure SQL database using Azure AD identity username and password

Server=tcp:myserver.database.windows.net,1433;Authentication=Active Directory Password;Database=myDataBase;UID=myUser@myDomain;PWD=myPassword;

If we want communication to be always encrypted

Data Source=myServer;Initial Catalog=myDB;Integrated Security=true;Column Encryption Setting=enabled;

FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect