How to get Azure SQL database connection string

How to get Azure SQL database connection string

The Azure SQL database 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.

How to get Azure SQL database connection string

It’s easy to get the connection string of your Azure SQL database using the below-mentioned steps.

  1. Login to Azure Portal.
  2. Search for SQL databases and click on the search result SQL databases.
azure sql database connection string

3. On the SQL databases window, you can able to 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.

connection string azure sql database

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

Find Azure SQL database connection string

Click on the ADO.NET tab to see the connection string for ADO.NET and it will be like below.,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.


Click on the ODBC tab to see the connection string for ODBC.

Driver={ODBC Driver 13 for SQL Server};,1433;Database=TsInfoSQLNewDB;Uid=rajkishore;Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;

Then if you will click on the PHP tab, you will see the connection string for PHP and it will be like below.

// PHP Data Objects(PDO) Sample Code:
try {
    $conn = new PDO("sqlsrv:server =,1433; Database = TsInfoSQLNewDB", "rajkishore", "{your_password_here}");
catch (PDOException $e) {
    print("Error connecting to SQL Server.");

// SQL Server Extension Sample Code:
$connectionInfo = array("UID" => "rajkishore", "pwd" => "{your_password_here}", "Database" => "TsInfoSQLNewDB", "LoginTimeout" => 30, "Encrypt" => 1, "TrustServerCertificate" => 0);
$serverName = ",1433";
$conn = sqlsrv_connect($serverName, $connectionInfo);

Finally, click on the Go tab to see the connectiontion string and it will be like below

// Go connection Sample Code:
package main
import (
	_ ""

var db *sql.DB
var server = ""
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 {

You may like following the below articles

Wrapping Up

In this article, we discussed how to find Azure SQL database connection string using the above instruction. Hope this information will help you. Thanks for reading this article !!!