In this article, I’ll share everything you need about Azure SQL Database connection strings to ensure your applications connect securely and efficiently.
Table of Contents
Azure SQL Database Connection String
We need the Azure SQL Connection String from our local Visual Studio to connect to the Azure SQL Database in the cloud. 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 String Formats for Different Programming Languages
ADO.NET Connection String
For .NET developers, the ADO.NET connection string is most common:
Server=tcp:{your_server}.database.windows.net,1433;Database={your_database};User ID={your_username};Password={your_password};Encrypt=true;Connection Timeout=30;
When working with .NET applications, you’ll use the Microsoft.Data.The sqlClient package has replaced the older system.Data.SqlClient for Azure SQL connections.
JDBC Connection String for Java
Java developers will use the JDBC format:
jdbc:sqlserver://{your_server}.database.windows.net:1433;database={your_database};user={your_username}@{your_server};password={your_password};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
ODBC Connection String
For applications using ODBC drivers:
Driver={ODBC Driver 18 for SQL Server};Server=tcp:{your_server}.database.windows.net,143Connection 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 Strings.
Essential Connection String Parameters
Beyond the basics, these parameters can optimize your connection:
| Parameter | Description | Recommended Value |
|---|---|---|
| Connect Timeout | Max time (seconds) to wait for connection | 30 |
| Encrypt | Forces TLS encryption | true |
| TrustServerCertificate | Validates server certificate | false |
| ApplicationIntent | Read-write or read-only | ReadWrite |
| MultipleActiveResultSets | Enable MARS | false |
| Max Pool Size | Maximum connections in pool | 100 |
Security Best Practices for Connection Strings
Below are the best practices.
- Never hardcode connection strings in your application source code
- Use environment variables or secure configuration stores like Azure Key Vault
- Implement the principle of least privilege for database users
- Enable Always Encrypted for sensitive data columns
- Regularly rotate database credentials
Conclusion
This Azure article discusses the Azure SQL database connection string. Thanks for reading this article !!!
You may also like the following articles below

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, 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.
