Azure SQL 数据库和 Azure SQL 托管实例连接和查询文章Azure SQL Database and Azure SQL Managed Instance connect and query articles

适用于:是 Azure SQL 数据库 是Azure SQL 托管实例 APPLIES TO: yesAzure SQL Database yesAzure SQL Managed Instance

以下文档包含 Azure 示例的链接,演示如何连接和查询 Azure SQL 数据库以及 Azure SQL 托管实例。The following document includes links to Azure examples showing how to connect and query Azure SQL Database and Azure SQL Managed Instance. 有关传输级别安全性的相关建议,请参阅数据库连接的 TLS 注意事项For some related recommendations for Transport Level Security, see TLS considerations for database connectivity.

快速入门Quickstarts

快速入门Quickstart 说明Description
SQL Server Management StudioSQL Server Management Studio 本快速入门演示如何使用 SSMS 连接到数据库,并使用 Transact-SQL 语句在数据库中查询、插入、更新和删除数据。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 StudioAzure Data Studio 本快速入门演示如何使用 Azure Data Studio 连接到数据库,然后使用 Transact-SQL (T-SQL) 语句创建在 Azure Data Studio 教程中使用的 TutorialDB。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 门户Azure portal 本快速入门演示如何使用查询编辑器连接到数据库(仅限 Azure SQL 数据库),然后使用 Transact-SQL 语句在数据库中查询、插入、更新和删除数据。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 CodeVisual Studio Code 本快速入门演示如何使用 Visual Studio Code 连接到数据库,并使用 Transact-SQL 语句在数据库中查询、插入、更新和删除数据。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 与 Visual Studio 配合使用.NET with Visual Studio 本快速入门演示如何使用 .NET framework 与 Visual Studio 来创建连接到数据库的 C# 程序,并使用 Transact-SQL 语句查询数据。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.NET core 本快速入门演示如何在 Windows/Linux/macOS 中使用 .NET Core 创建连接到数据库的 C# 程序,并使用 Transact-SQL 语句查询数据。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.
GoGo 本快速入门演示如何使用 Go 连接到数据库。This quickstart demonstrates how to use Go to connect to a database. 此外演示了用于查询和修改数据的 Transact-SQL 语句。Transact-SQL statements to query and modify data are also demonstrated.
JavaJava 本快速入门演示如何使用 Java 连接到数据库,并使用 Transact-SQL 语句查询数据。This quickstart demonstrates how to use Java to connect to a database and then use Transact-SQL statements to query data.
Node.jsNode.js 本快速入门演示如何使用 Node.js 创建连接到数据库的程序,并使用 Transact-SQL 语句查询数据。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.
PHPPHP 本快速入门演示如何使用 PHP 创建连接到数据库的程序,并使用 Transact-SQL 语句来查询数据。This quickstart demonstrates how to use PHP to create a program to connect to a database and use Transact-SQL statements to query data.
PythonPython 本快速入门演示如何使用 Python 连接到 Azure SQL 数据库,并使用 Transact-SQL 语句查询数据。This quickstart demonstrates how to use Python to connect to a database and use Transact-SQL statements to query data.
RubyRuby 本快速入门演示如何使用 Ruby 创建连接到数据库的程序,并使用 Transact-SQL 语句查询数据。This quickstart demonstrates how to use Ruby to create a program to connect to a database and use Transact-SQL statements to query data.

数据库连接的 TLS 注意事项TLS considerations for database connectivity

Azure 提供或支持的所有驱动程序使用传输层安全性 (TLS) 连接到 Azure SQL 数据库或 Azure SQL 托管实例中的数据库。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. 对于到 SQL Server 实例、Azure SQL 数据库中的数据库,或 Azure SQL 托管实例的实例的所有连接,我们建议所有应用程序设置以下配置或其等效项: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 = OnEncrypt = On
  • TrustServerCertificate = OffTrustServerCertificate = Off

某些系统对于这些配置关键字使用不同但等效的关键字。Some systems use different yet equivalent keywords for those configuration keywords. 这些配置可确保客户端驱动程序验证从服务器收到的 TLS 证书的标识。These configurations ensure that the client driver verifies the identity of the TLS certificate received from the server.

如果需要符合支付卡行业 - 数据安全标准 (PCI-DSS),我们还建议你在客户端上禁用 TLS 1.1 和 1.0。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).

默认情况下,非 Microsoft 驱动程序可能不会使用 TLS。Non-Microsoft drivers might not use TLS by default. 连接到 Azure SQL 数据库或 Azure SQL 托管实例时,这可能是一个因素。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

可以使用各种库和框架连接到 Azure SQL 数据库或 Azure SQL 托管实例。You can use various libraries and frameworks to connect to Azure SQL Database or Azure SQL Managed Instance. 请查看快速入门教程,了解 C#、Java、Node.js、PHP、Python 等编程语言的快速入门方式。Check out our Get started tutorials to quickly get started with programming languages such as C#, Java, Node.js, PHP, and Python. 然后使用基于 Linux 或 Windows 的 SQL Server 或基于 macOS 的 Docker 生成一个应用。Then build an app by using SQL Server on Linux or Windows or Docker on macOS.

下表列出的连接库或驱动程序可供客户端应用程序用于通过多种语言连接到在本地或云中运行的 SQL Server 并使用该 SQL Server。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. 可以在 Linux、Windows 或 Docker 上使用它们,并将其用于连接到 Azure SQL 数据库、Azure SQL 托管实例和 Azure SQL 数据仓库。You can use them on Linux, Windows, or Docker and use them to connect to Azure SQL Database, Azure SQL Managed Instance, and Azure SQL Data Warehouse.

语言Language 平台Platform 其他资源Additional resources 下载Download 入门Get started
C#C# Windows、Linux、macOSWindows, Linux, macOS 用于 SQL Server 的 Microsoft ADO.NETMicrosoft ADO.NET for SQL Server 下载Download 入门Get started
JavaJava Windows、Linux、macOSWindows, Linux, macOS 用于 SQL Server 的 Microsoft JDBC 驱动程序Microsoft JDBC driver for SQL Server 下载Download 入门Get started
PHPPHP Windows、Linux、macOSWindows, Linux, macOS 用于 SQL Server 的 PHP SQL 驱动程序PHP SQL driver for SQL Server 下载Download 入门Get started
Node.jsNode.js Windows、Linux、macOSWindows, Linux, macOS 用于 SQL Server 的 Node.js 驱动程序Node.js driver for SQL Server 安装Install 入门Get started
PythonPython Windows、Linux、macOSWindows, Linux, macOS Python SQL 驱动程序Python SQL driver 安装选项:Install choices:
* pymssql* pymssql
* pyodbc* pyodbc
入门Get started
RubyRuby Windows、Linux、macOSWindows, Linux, macOS 用于 SQL Server 的 Ruby 驱动程序Ruby driver for SQL Server 安装Install 入门Get started
C++C++ Windows、Linux、macOSWindows, Linux, macOS Microsoft ODBC Driver for SQL ServerMicrosoft ODBC driver for SQL Server 下载Download

下表列出了客户端应用程序可以与 SQL Server、Azure SQL 数据库、Azure SQL 托管实例或 Azure Synapse Analytics 一起使用的对象关系映射 (ORM) 框架和 Web 框架的示例。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. 可以在 Linux、Windows 或 Docker 上使用这些框架。You can use the frameworks on Linux, Windows, or Docker.

语言Language 平台Platform ORMORM(s)
C#C# Windows、Linux、macOSWindows, Linux, macOS 实体框架Entity Framework
Entity Framework CoreEntity Framework Core
JavaJava Windows、Linux、macOSWindows, Linux, macOS Hibernate ORMHibernate ORM
PHPPHP Windows、Linux、macOSWindows, Linux, macOS Laravel (Eloquent)Laravel (Eloquent)
DoctrineDoctrine
Node.jsNode.js Windows、Linux、macOSWindows, Linux, macOS Sequelize ORMSequelize ORM
PythonPython Windows、Linux、macOSWindows, Linux, macOS DjangoDjango
RubyRuby Windows、Linux、macOSWindows, Linux, macOS Ruby on RailsRuby on Rails

后续步骤Next steps