Azure SQL Database and Azure SQL Managed Instance connect and query articles

Applies to: Azure SQL Database Azure SQL Managed Instance

The following document includes links to Azure examples showing how to connect and query Azure SQL Database and Azure SQL Managed Instance. For some related recommendations for Transport Level Security, see TLS considerations for database connectivity.

Quickstarts

Quickstart Description
SQL Server Management Studio This quickstart demonstrates how to use SSMS to connect to a 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 a 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 database (Azure SQL Database only), 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 a 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 a 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 a database and use Transact-SQL statements to query data.
Go This quickstart demonstrates how to use Go to connect to a database. Transact-SQL statements to query and modify data are also demonstrated.
Java This quickstart demonstrates how to use Java to connect to a 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 a database and use Transact-SQL statements to query data.
PHP This quickstart demonstrates how to use PHP to create a program to connect to a database and use Transact-SQL statements to query data.
Python This quickstart demonstrates how to use Python to connect to a database and use Transact-SQL statements to query data.
Ruby This quickstart demonstrates how to use Ruby to create a program to connect to a database and use Transact-SQL statements to query data.

Get server connection information

Get the connection information you need to connect to the database in Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.

  1. Sign in to the Azure portal.

  2. Navigate to the SQL Databases or SQL Managed Instances page.

  3. On the Overview page, review the fully qualified server name next to Server name for the database in Azure SQL Database or the fully qualified server name (or IP address) next to Host for an Azure SQL Managed Instance or SQL Server on Azure VM. To copy the server name or host name, hover over it and select the Copy icon.

Note

For connection information for SQL Server on Azure VM, see Connect to a SQL Server instance.

Get ADO.NET connection information (optional - SQL Database only)

  1. Navigate to the database pane in the Azure portal and, under Settings, select Connection strings.

  2. Review the complete ADO.NET connection string.

    Screenshot showing the ADO.NET connection string.

  3. Copy the ADO.NET connection string if you intend to use it.

TLS considerations for database connectivity

Transport Layer Security (TLS) is used by all drivers that Azure supplies or supports for connecting to databases in Azure SQL Database or Azure SQL Managed Instance. No special configuration is necessary. For all connections to a SQL Server instance, a database in Azure SQL Database, or an instance of Azure SQL Managed Instance, 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 or Azure SQL Managed Instance. 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 or Azure SQL Managed Instance. You can then build an app by using SQL Server on Linux or Windows, or a SQL Server container on Linux.

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 in containers, and use them to connect to Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics.

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

Data-access frameworks

The following table lists examples of object-relational mapping (ORM) frameworks and web frameworks that client applications can use with SQL Server, Azure SQL Database, Azure SQL Managed Instance, or Azure Synapse Analytics. You can use the frameworks on Linux, Windows, or in containers.

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

Next steps