
The Azure SQL connection string is a piece of important information that is required for any application to connect to the Azure SQL database. In this Azure article, we will discuss the steps to get the Azure SQL database connection string.
Table of Contents
How to get Azure SQL connection string
It’s easy to get the connection string of your Azure SQL database using the below-mentioned steps.
- Login to Azure Portal.
- Search for SQL databases and click on the search result SQL databases.

3. On the SQL databases window, you can see the lists of Azure SQL databases you have created. Click on the specific database for the one you want to find the connection string.

4. Click on the Connection strings link from the left navigation below.

Click on the ADO.NET tab to see the connection string for ADO.NET, and it will be like below.
Server=tcp:tsinfo.database.windows.net,1433;Initial Catalog=TsInfoSQLNewDB;Persist Security Info=False;User ID=rajkishore;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Then click on the JDBC tab to see the connection string for JDBC.
jdbc:sqlserver://tsinfo.database.windows.net:1433;database=TsInfoSQLNewDB;user=rajkishore@tsinfo;password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
Click on the ODBC tab to see the connection string for ODBC.
Driver={ODBC Driver 13 for SQL Server};Server=tcp:tsinfo.database.windows.net,1433;Database=TsInfoSQLNewDB;Uid=rajkishore;Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
Then, if you click on the PHP tab, you will see the connection string for PHP, and it will be like below.
<?php
// PHP Data Objects(PDO) Sample Code:
try {
$conn = new PDO("sqlsrv:server = tcp:tsinfo.database.windows.net,1433; Database = TsInfoSQLNewDB", "rajkishore", "{your_password_here}");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
print("Error connecting to SQL Server.");
die(print_r($e));
}
// SQL Server Extension Sample Code:
$connectionInfo = array("UID" => "rajkishore", "pwd" => "{your_password_here}", "Database" => "TsInfoSQLNewDB", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0);
$serverName = "tcp:tsinfo.database.windows.net,1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);
?>
Finally, click on the Go tab to see the connection string, and it will be like the below
// Go connection Sample Code:
package main
import (
_ "github.com/microsoft/go-mssqldb"
"database/sql"
"context"
"log"
"fmt"
"errors"
)
var db *sql.DB
var server = "tsinfo.database.windows.net"
var port = 1433
var user = "rajkishore"
var password = "<your_password>"
var database = "TsInfoSQLNewDB"
func main() {
// Build connection string
connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%d;database=%s;",
server, user, password, port, database)
var err error
// Create connection pool
db, err = sql.Open("sqlserver", connString)
if err != nil {
log.Fatal("Error creating connection pool: ", err.Error())
}
ctx := context.Background()
err = db.PingContext(ctx)
if err != nil {
log.Fatal(err.Error())
}
fmt.Printf("Connected!")
}
Azure SQL Database Connection String
We need the Azure SQL Connection String to connect to the Azure SQL Database in the cloud from our local Visual Studio. We need to specify the connection strings in the config file to connect to the Azure SQL Database.
Provider System.Data.SqlClient
Standard
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="MynewConnection"
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Initial Catalog=YourInitialCatalogName;User ID={YourUserName};Password={YourPassword};Encrypt=True;TrustServerCertificate=False;Connection Timeout=30"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

MARS enabled
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="MynewConnection"
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Initial Catalog=YourInitialCatalogName;User ID={YourUserName};Password={YourPassword};Encrypt=True;Trusted_Connection=False;MultipleActiveResultSets=True;Connection Timeout=30"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

Azure AD Identity With Windows Authentication
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="MynewConnection"
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Authentication=Active Directory Integrated;Database=yourdatabasename"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

With Encrypted
<connectionStrings>
<add name="MynewConnection"
connectionString="Data Source=YourServerName;Initial Catalog=YourDBName;Integrated Security=true;Column Encryption Setting=enabled;"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>

Connection Strings For .NET Framework Data Provider for SQL Server
Standard
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Database=YourDataBaseName;User ID=YourUserID;Password=YourPassword;Trusted_Connection=False;Encrypt=True;
MARS enabled
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Database=YourDataBaseName;User ID=YourUserID;Password=YourPassword;Trusted_Connection=False;Encrypt=True;MultipleActiveResultSets=True;
Azure AD Identity With Windows Authentication
connectionString="Server=tcp:YourServerName.database.windows.net,1433;Authentication=Active Directory Integrated;Database=YourdatabaseName;
With Encrypted
Data Source=YourServerName;Initial Catalog=YourInitialCatalogName;Integrated Security=true;Column Encryption Setting=enabled;
Connection Strings For OLE DB Driver for SQL Server
With SQL Authentication
Provider=MSOLEDBSQL;Data Source=YourServerName;Initial Catalog=YourInitialCatalog;Authentication=SQLPassword;User ID=YourUserName;Password=YourPassword;Use Encryption for Data=true;
Windows authentication with SSPI
Provider=MSOLEDBSQL;Data Source=YourServerName;Initial Catalog=YourInitialCatalog;Authentication=ActiveDirectoryIntegrated;Use Encryption for Data=true;
AAD integrated authentication
Provider=MSOLEDBSQL;Data Source=YourServerName;Initial Catalog=YourInitialCatalog;Authentication=ActiveDirectoryIntegrated;Use Encryption for Data=true;
So these are a few lists of Azure SQL Database Connection String.
You may like following the articles below
- How to create a table in Azure SQL database
- How to rename the Azure SQL database
- How to backup Azure SQL database
- How To Change User ID and Password For Azure SQL Server Database
- How To Revert SQL Azure Database
- How To Deploy SQL Database To Azure
Wrapping Up
In this article, we discussed how to find Azure SQL database connection string using the above instructions. I hope this information will help you. Thanks for reading this article !!!

I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.