Quickstarts: Azure SQL Database connect and query

The following document includes links to Azure examples showing how to connect and query an Azure SQL database. It also provides some recommendations for Transport Level Security.

Quickstarts

SQL Server Management Studio This quickstart demonstrates how to use SSMS to connect to an Azure SQL database, and then use Transact-SQL statements to query, insert, update, and delete data in the database.
Azure Data Studio This quickstart demonstrates how to use Azure Data Studio to connect to an Azure SQL database, and then use Transact-SQL (T-SQL) statements to create the TutorialDB used in Azure Data Studio tutorials.
Azure portal This quickstart demonstrates how to use the Query editor to connect to a SQL database, and then use Transact-SQL statements to query, insert, update, and delete data in the database.
Visual Studio Code This quickstart demonstrates how to use Visual Studio Code to connect to an Azure SQL database, and then use Transact-SQL statements to query, insert, update, and delete data in the database.
.NET with Visual Studio This quickstart demonstrates how to use the .NET framework to create a C# program with Visual Studio to connect to an Azure SQL database and use Transact-SQL statements to query data.
.NET core This quickstart demonstrates how to use .NET Core on Windows/Linux/macOS to create a C# program to connect to an Azure SQL database and use Transact-SQL statements to query data.
Go This quickstart demonstrates how to use Go to connect to an Azure SQL database. Transact-SQL statements to query and modify data are also demonstrated.
Java This quickstart demonstrates how to use Java to connect to an Azure SQL database and then use Transact-SQL statements to query data.
Node.js This quickstart demonstrates how to use Node.js to create a program to connect to an Azure SQL database and use Transact-SQL statements to query data.
PHP This quickstart demonstrates how to use PHP to create a program to connect to an Azure SQL database and use Transact-SQL statements to query data.
Python This quickstart demonstrates how to use Python to connect to an Azure SQL database and use Transact-SQL statements to query data.
Ruby This quickstart demonstrates how to use Ruby to create a program to connect to an Azure SQL database and use Transact-SQL statements to query data.

TLS considerations for SQL Database connectivity

Transport Layer Security (TLS) is used by all drivers that Microsoft supplies or supports for connecting to Azure SQL Database. No special configuration is necessary. For all connections to SQL Server or to Azure SQL Database, we recommend that all applications set the following configurations, or their equivalents:

  • Encrypt = On
  • TrustServerCertificate = Off

Some systems use different yet equivalent keywords for those configuration keywords. These configurations ensure that the client driver verifies the identity of the TLS certificate received from the server.

We also recommend that you disable TLS 1.1 and 1.0 on the client if you need to comply with Payment Card Industry - Data Security Standard (PCI-DSS).

Non-Microsoft drivers might not use TLS by default. This can be a factor when connecting to Azure SQL Database. Applications with embedded drivers might not allow you to control these connection settings. We recommend that you examine the security of such drivers and applications before using them on systems that interact with sensitive data.

Libraries

You can use various libraries and frameworks to connect to Azure SQL Database. Check out our Get started tutorials to quickly get started with programming languages such as C#, Java, Node.js, PHP, and Python. Then build an app by using SQL Server on Linux or Windows or Docker on macOS.

The following table lists connectivity libraries or drivers that client applications can use from a variety of languages to connect to and use SQL Server running on-premises or in the cloud. You can use them on Linux, Windows, or Docker and use them to connect to Azure SQL Database and Azure SQL Data Warehouse.

Language Platform Additional resources Download Get started
C# Windows, Linux, macOS Microsoft ADO.NET for SQL Server Download Get started
Java Windows, Linux, macOS Microsoft JDBC driver for SQL Server Download Get started
PHP Windows, Linux, macOS PHP SQL driver for SQL Server Download Get started
Node.js Windows, Linux, macOS Node.js driver for SQL Server Install Get started
Python Windows, Linux, macOS Python SQL driver Install choices:
* pymssql
* pyodbc
Get started
Ruby Windows, Linux, macOS Ruby driver for SQL Server Install Get started
C++ Windows, Linux, macOS Microsoft ODBC driver for SQL Server Download

The following table lists examples of object-relational mapping (ORM) frameworks and web frameworks that client applications can use with SQL Server running on-premises or in the cloud. You can use the frameworks on Linux, Windows, or Docker and use them to connect to SQL Database and SQL Data Warehouse.

Language Platform ORM(s)
C# Windows, Linux, macOS Entity Framework
Entity Framework Core
Java Windows, Linux, macOS Hibernate ORM
PHP Windows, Linux, macOS Laravel (Eloquent)
Doctrine
Node.js Windows, Linux, macOS Sequelize ORM
Python Windows, Linux, macOS Django
Ruby Windows, Linux, macOS Ruby on Rails

Next steps