หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Applies to:
Azure SQL Database
Azure SQL Managed Instance
This article links to examples that show how to connect to and query Azure SQL Database and Azure SQL Managed Instance. For Transport Layer Security (TLS) recommendations, see TLS considerations for database connectivity.
Watch this video in the Azure SQL Database essentials series for a brief connect and query overview:
Quickstarts
| Quickstart | Description |
|---|---|
| SQL Server Management Studio (SSMS) | 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 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 .NET and C# with Visual Studio to connect to a database and query data with Transact-SQL statements. |
| .NET | This quickstart demonstrates how to use .NET on Windows, Linux, or macOS to connect to a database and query data with Transact-SQL statements. |
| 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 need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
Sign in to the Azure portal.
Navigate to the SQL Databases or SQL Managed Instances page.
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)
Navigate to the database pane in the Azure portal and, under Settings, select Connection strings.
Review the complete ADO.NET connection string.
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 Microsoft 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 SQL pool in Azure Synapse Analytics, a database in Azure SQL Database, or an instance of Azure SQL Managed Instance, we recommend that the applications set the following connection parameters or their equivalents:
Encrypt = OnTrustServerCertificate = Off- Optionally,
HostNameInCertificate = full-hostname-of-serviceif the client uses a different address to connect and the TDS driver supports this option.
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.
Drivers and frameworks
Use the Microsoft SQL drivers and frameworks article to choose a driver or provider and, when applicable, a framework or data access library. To build an application that connects to Azure SQL Database or Azure SQL Managed Instance, use the language quickstarts in this article.
Related content
- Azure SQL Database and Azure Synapse Analytics connectivity architecture
- Quickstart: Use .NET (C#) to query a database
- Quickstart: Use Go to query a database in Azure SQL Database or Azure SQL Managed Instance
- Quickstart: Use Node.js to query a database in Azure SQL Database or Azure SQL Managed Instance
- Quickstart: Use PHP to query a database in Azure SQL Database or Azure SQL Managed Instance
- Quickstart: Use Python to query a database in Azure SQL Database or Azure SQL Managed Instance
- Quickstart: Use Ruby to query a database in Azure SQL Database or Azure SQL Managed Instance
- Use Java and JDBC with Azure SQL Database
- Install sqlcmd and bcp the SQL Server command-line tools on Linux
- sqlcmd
- Connect resiliently to SQL with ADO.NET
- Connect resiliently to SQL with PHP