如何在 Azure 门户中预配 Windows SQL Server 虚拟机How to provision a Windows SQL Server virtual machine in the Azure portal

本指南详细介绍在 Azure 门户中创建 Windows SQL Server 虚拟机时可用的不同选项。This guide provides details on the different options available when you create a Windows SQL Server virtual machine in the Azure portal. 本文介绍更多 SQL Server VM 快速入门中未提及的配置选项,为单个预配任务提供更丰富的选择。This article covers more configuration options than the SQL Server VM quickstart, which goes more through one possible provisioning task.

借助本指南创建你自己的 SQL Server VM。Use this guide to create your own SQL Server VM. 或使用它作为参考,了解 Azure 门户中可用的选项。Or, use it as a reference for the available options in the Azure portal.

Tip

如果对 SQL Server 虚拟机有任何疑问,请参阅常见问题解答If you have questions about SQL Server virtual machines, see the Frequently Asked Questions.

如果没有 Azure 订阅,可在开始前创建一个试用帐户If you don't have an Azure subscription, create a trial account before you begin.

创建 SQL Server 虚拟机时,可从虚拟机库中选择一个预配置的映像。When you create a SQL Server virtual machine, you can select one of several pre-configured images from the virtual machine gallery. 以下步骤演示如何选择一个 SQL Server 2017 映像。The following steps demonstrate how to select one of the SQL Server 2017 images.

  1. 使用帐户登录到 Azure 门户Log in to the Azure portal using your account.

  2. 在 Azure 门户中,单击“创建资源” 。On the Azure portal, click Create a resource. 该门户会打开“新建”窗口。 The portal opens the New window.

  3. 在“新建” 窗口中,单击“虚拟机” ,然后单击“全部查看” 。In the New window, click Virtual Machines and then click See all.

    “新建计算”窗口

  4. 在搜索字段中,键入“SQL Server 2017” ,然后按 Enter。In the search field, type SQL Server 2017, and press ENTER.

  5. 勾选“Microsoft”作为发布者。 Check Microsoft for the publisher.

    Azure 虚拟机窗口

  6. 查看可用的 SQL Server 映像。Review the available SQL Server images. 每个映像均可标识 SQL Server 版本和操作系统。Each image identifies a SQL Server version and an operating system.

  7. 选择名为“免费 SQL Server 许可证: Windows Server 2016 上的 SQL Server 2017 Developer”的映像。Select the image named Free SQL Server License: SQL Server 2017 Developer on Windows Server 2016.

    Tip

    本演示使用 Developer(开发人员)版,因为该版本是 SQL Server 的完整功能版本,并且可免费用于开发测试。The Developer edition is used in this walkthrough because it is a full-featured, free edition of SQL Server for development testing. 只需支付运行 VM 的成本。You pay only for the cost of running the VM. 但是,本教程中使用的映像可随意选择。However, you are free to choose any of the images to use in this walkthrough. 有关可用映像的说明,请参阅 SQL Server Microsoft 虚拟机概述For a description of available images, see the SQL Server Windows Virtual Machines overview.

    Tip

    SQL Server 的许可费用包含在所创建的 VM 的每秒定价中,并随版本和内核而有所不同。Licensing costs for SQL Server are incorporated into the per-second pricing of the VM you create and varies by edition and cores. 但是,SQL Server 开发人员版可免费用于开发/测试(不可用于生产),而 SQL Express 可免费用于轻型工作负荷(1 GB 内存以内,10 GB 存储以内)。However, SQL Server Developer edition is free for development/testing (not production), and SQL Express is free for lightweight workloads (less than 1 GB of memory, less than 10 GB of storage). 还可选择自带许可 (BYOL),只支付 VM 费用。You can also bring-your-own-license (BYOL) and pay only for the VM. 这些映像名称的前缀为 {BYOL}。Those image names are prefixed with {BYOL}.

    有关这些选项的详细信息,请参阅 SQL Server Azure VM 定价指南For more information on these options, see Pricing guidance for SQL Server Azure VMs.

  8. 在“选择部署模型”下面,确认已选择“Resource Manager”。 Under Select a deployment model, verify that Resource Manager is selected. 对于新虚拟机,建议使用“Resource Manager”部署模型。Resource Manager is the recommended deployment model for new virtual machines.

  9. 选择“创建” 。Select Create.

配置选项Configuration options

有五个用于配置 SQL Server 虚拟机的选项卡。There are five tabs for configuring a SQL Server virtual machine.

步骤Step 说明Description
基础知识Basics 配置基本设置Configure basic settings
大小Size 选择虚拟机大小Choose virtual machine size
设置Settings 配置可选功能Configure optional features
SQL Server 设置SQL Server settings 配置 SQL Server 设置Configure SQL server settings
摘要Summary 查看摘要Review the summary

1.配置基本设置1. Configure basic settings

在“基本信息”选项卡中提供以下信息: On the Basics tab, provide the following information:

  • 输入唯一的虚拟机 名称Enter a unique virtual machine Name.

  • 选择“SSD”作为 VM 磁盘类型可获得最佳性能。 Select SSD for VM disk type for optimal performance.

  • 指定 VM 上本地管理员帐户的 用户名Specify a User name for the local administrator account on the VM. 此帐户还会被添加到 SQL Server sysadmin 固定服务器角色。This account is also added to the SQL Server sysadmin fixed server role.

  • 提供一个强 密码Provide a strong Password.

  • 如果有多个订阅,验证该订阅是否是新 VM 的正确订阅。If you have multiple subscriptions, verify that the subscription is correct for the new VM.

  • 在“资源组”框中,键入新资源组的名称。 In the Resource group box, type a name for a new resource group. 此外,若要使用现有的资源组,请单击“使用现有项”。Alternatively, to use an existing resource group click Use existing. 资源组是 Azure(虚拟机、存储帐户、虚拟网络等)中相关资源的集合。A resource group is a collection of related resources in Azure (virtual machines, storage accounts, virtual networks, etc.).

    Note

    如果只是测试或了解 Azure 中的 SQL Server 部署,使用新的资源组很有帮助。Using a new resource group is helpful if you are just testing or learning about SQL Server deployments in Azure. 测试完成后,删除资源组会自动删除 VM 和与该资源组相关联的所有资源。After you finish with your test, delete the resource group to automatically delete the VM and all resources associated with that resource group. 有关资源组的详细信息,请参阅 Azure Resource Manager 概述For more information about resource groups, see Azure Resource Manager Overview.

  • 针对 Azure 区域选择用于托管该部署的“位置”。 Select a Location for the Azure region to host this deployment.

  • 单击“确定” 保存设置。Click OK to save the settings.

    SQL 基本信息窗口

2.选择虚拟机大小2. Choose virtual machine size

执行“大小”设置步骤时,请在“选择大小”窗口中选择虚拟机大小。 On the Size step, choose a virtual machine size in the Choose a size window. 窗口最初会根据所选映像显示建议的计算机大小。The window initially displays recommended machine sizes based on the image you selected.

Important

在“选择大小” 窗口中显示的每月估计成本不包括 SQL Server 许可成本。The estimated monthly cost displayed on the Choose a size window does not include SQL Server licensing costs. 此预估费用只是 VM 的成本。This estimate is the cost of the VM alone. 对于 SQL Server 的 Express 和开发人员版本,这是估计的总成本。For the Express and Developer editions of SQL Server, this estimate is the total estimated cost. 对于其他版本,请参阅“Windows 虚拟机定价”页并选择 SQL Server 的目标版本。For other editions, see the Windows Virtual Machines pricing page and select your target edition of SQL Server. 另请参阅 SQL Server Azure VM 的定价指南虚拟机的大小Also see the Pricing guidance for SQL Server Azure VMs and Sizes for virtual machines.

SQL VM 大小选项

对于生产工作负荷,请参阅 Azure 虚拟机中 SQL Server 的性能最佳做法中建议的计算机大小和配置。For production workloads, see the recommended machine sizes and configuration in Performance best practices for SQL Server in Azure Virtual Machines.

Note

有关虚拟机大小的详细信息,请参阅虚拟机大小For more information about virtual machine sizes, Sizes for virtual machines.

选择计算机大小,并单击“选择” 。Choose your machine size, and then click Select.

3.配置可选功能3. Configure optional features

在“设置”窗口中,为虚拟机配置 Azure 存储、网络和监视。 On the Settings window, configure Azure storage, networking, and monitoring for the virtual machine.

  • 在“存储”的“使用托管磁盘”下,选择“是”。 Under Storage, select Yes under use Managed Disks.

    Note

    Azure 建议为 SQL Server 使用托管磁盘。Azure recommends Managed Disks for SQL Server. 托管磁盘在后台处理存储。Managed Disks handles storage behind the scenes. 此外,当使用托管磁盘的虚拟机位于同一可用性集中时,Azure 会分发存储资源以提供适当冗余。In addition, when virtual machines with Managed Disks are in the same availability set, Azure distributes the storage resources to provide appropriate redundancy. 有关详细信息,请参阅 [Azure 托管磁盘概述][../managed-disks-overview.md)。For more information, see [Azure Managed Disks Overview][../managed-disks-overview.md). 有关可用性集中托管磁盘的具体信息,请参阅为可用性集中的 VM 使用托管磁盘For specifics about managed disks in an availability set, see Use managed disks for VMs in availability set.

  • 在“网络”下 ,选择“选择公共入站端口”列表中的任意入站端口 。Under Network, select any inbound ports that in the Select public inbound ports list. 例如,如果想要远程桌面连接到 VM,则选择“RDP (3389)” 端口。For example, if you want to remote desktop into the VM, select the RDP (3389) port.

    入站端口

    Note

    可以选择“MS SQL (1433)” 端口以远程访问 SQL Server。You can select the MS SQL (1433) port to access SQL Server remotely. 但是,这在此处并不必要,因为“SQL Server 设置” 步骤也提供此选项。However, this is not necessary here, because the SQL Server settings step provides this option as well. 如果在此步骤中选择了端口 1433,则无论在“SQL Server 设置” 步骤中选择了哪一项,都会打开该端口。If you do select port 1433 at this step, it will be opened irregardless of your selections in the SQL Server settings step.

    你可以对网络设置进行其他更改,也可以保留默认值。You can make other changes to network settings, or keep the default values.

  • 默认情况下,Azure 会对为 VM 指定的同一个存储帐户启用“监视”功能。 Azure enables Monitoring by default with the same storage account designated for the VM. 可以在此处更改这些设置。You can change these settings here.

  • 对于本演示,可以在“可用性集”下保留默认设置“无”。 Under Availability set, you can leave the default of none for this walkthrough. 如果计划设置 SQL AlwaysOn 可用性组,可以对可用性进行配置,避免重新创建虚拟机。If you plan to set up SQL AlwaysOn Availability Groups, configure the availability to avoid recreating the virtual machine. 有关详细信息,请参阅 管理虚拟机的可用性For more information, see Manage the Availability of Virtual Machines.

配置完这些设置后,请单击“确定”。 When you are done configuring these settings, click OK.

4.配置 SQL Server 设置4. Configure SQL server settings

在“SQL Server 设置”选项卡上,配置 SQL Server 的特定设置和优化。 On the SQL Server settings tab, configure specific settings and optimizations for SQL Server. 可以为 SQL Server 配置的设置包括以下各项:The settings that you can configure for SQL Server include the following:

设置Setting
连接Connectivity
身份验证Authentication
存储配置Storage configuration
自动修补Automated Patching
自动备份Automated Backup
Azure 密钥保管库集成Azure Key Vault Integration
SQL Server 机器学习服务SQL Server Machine Learning Services

连接Connectivity

在“SQL 连接” 下,指定要对此 VM 上的 SQL Server 实例进行的访问类型。Under SQL connectivity, specify the type of access you want to the SQL Server instance on this VM. 对于本演示,请选择“公共(Internet)” 以允许从 Internet 上的计算机或服务连接到 SQL Server。For the purposes of this walkthrough, select Public (internet) to allow connections to SQL Server from machines or services on the internet. 选择此选项以后,Azure 会自动将防火墙和网络安全组配置为允许在所选端口上通信。With this option selected, Azure automatically configures the firewall and the network security group to allow traffic on the port selected.

SQL 连接选项

Tip

SQL Server 默认在已知端口 1433 上侦听。 By default, SQL Server listens on a well-known port, 1433. 为了提高安全性,请更改上一对话框中的端口,改成在非默认端口(例如 1401)上侦听。For increased security, change the port in the previous dialog to listen on a non-default port, such as 1401. 如果更改端口,则必须在任何客户端工具(例如 SSMS)中使用该端口进行连接。If you change the port, you must connect using that port from any client tools, such as SSMS.

若要通过 Internet 连接到 SQL Server,还必须启用下一部分中所述的“SQL Server 身份验证”。To connect to SQL Server via the internet, you also must enable SQL Server Authentication, which is described in the next section.

如果不希望启用通过 Internet 连接到数据库引擎这一功能,可选择以下选项之一:If you would prefer to not enable connections to the Database Engine via the internet, choose one of the following options:

  • 本地(仅在 VM 中) :仅允许从 VM 内部连接到 SQL Server。Local (inside VM only) to allow connections to SQL Server only from within the VM.
  • 私有(虚拟机内) :允许从同一虚拟网络中的虚拟机或服务连接到 SQL Server。Private (within Virtual Network) to allow connections to SQL Server from machines or services in the same virtual network.

一般情况下,选择方案允许的最严格连接可提高安全性。In general, improve security by choosing the most restrictive connectivity that your scenario allows. 但是,通过网络安全组规则和 SQL/Windows 身份验证的所有选项都是安全的。But all the options are securable through Network Security Group rules and SQL/Windows Authentication. 可以在创建 VM 后编辑“网络安全组”。You can edit Network Security Group after the VM is created. 有关详细信息,请参阅 Azure 虚拟机中 SQL Server 的安全注意事项For more information, see Security Considerations for SQL Server in Azure Virtual Machines.

身份验证Authentication

如果需要 SQL Server 身份验证,请在“ 启用 under 启用If you require SQL Server Authentication, click Enable under SQL authentication.

SQL Server 身份验证

Note

如果计划通过 Internet 来访问 SQL Server(“公共”连接选项),则必须在此处启用 SQL 身份验证。If you plan to access SQL Server over the internet (the Public connectivity option), you must enable SQL authentication here. 对 SQL Server 进行公共访问需要使用 SQL 身份验证。Public access to the SQL Server requires the use of SQL Authentication.

如果启用 SQL Server 身份验证,请指定“登录名”和“密码”。 If you enable SQL Server Authentication, specify a Login name and Password. 此登录名已配置为 SQL Server 身份验证登录名和 sysadmin 固定服务器角色的成员。This login name is configured as a SQL Server Authentication login and member of the sysadmin fixed server role. 若要详细了解身份验证模式,请参阅选择身份验证模式For more information about Authentication Modes, see Choose an Authentication Mode.

如果未启用 SQL Server 身份验证,可以在 VM 上使用本地管理员帐户连接到 SQL Server 实例。If you do not enable SQL Server Authentication, then you can use the local Administrator account on the VM to connect to the SQL Server instance.

存储配置Storage configuration

单击“存储配置” 以便指定存储要求。Click Storage configuration to specify the storage requirements.

Note

如果已手动将 VM 配置为使用标准存储,则此选项不可用。If you manually configured your VM to use standard storage, this option is not available. 自动存储优化只适用于高级存储。Automatic storage optimization is available only for Premium Storage.

Tip

每个滑块的停止数和上限取决于所选 VM 大小。The number of stops and the upper limits of each slider is dependent on the size of VM you selected. VM 较大且功能较强时,纵向扩展的余地越大。A larger and more powerful VM is able to scale up more.

可以将要求指定为每秒输入/输出操作数 (IOPs)、吞吐量(MB/秒)以及总存储大小。You can specify requirements as input/output operations per second (IOPs), throughput in MB/s, and total storage size. 可使用可调缩放性配置这些值。Configure these values by using the sliding scales. 可根据工作负荷更改这些存储设置。You can change these storage settings based on workload. 门户会根据这些要求自动计算要附加和配置的磁盘数。The portal automatically calculates the number of disks to attach and configure based on these requirements.

在“ 存储优化目标”下,选择以下选项之一:Under Storage optimized for, select one of the following options:

  • 常规 :默认设置,支持大多数工作负荷。General is the default setting and supports most workloads.
  • 事务处理 :针对传统数据库 OLTP 工作负荷优化存储。Transactional processing optimizes the storage for traditional database OLTP workloads.
  • 数据仓库 :针对分析和报告工作负荷优化存储。Data warehousing optimizes the storage for analytic and reporting workloads.

SQL 存储配置

自动修补Automated patching

自动修补 :默认处于启用状态。Automated patching is enabled by default. Azure 可以通过自动修补来自动修补 SQL Server 和操作系统。Automated patching allows Azure to automatically patch SQL Server and the operating system. 指定进行维护的具体日期(星期几)、时间和时长。Specify a day of the week, time, and duration for a maintenance window. Azure 会在维护时段进行修补。Azure performs patching in this maintenance window. 维护时段计划使用 VM 的时间区域设置。The maintenance window schedule uses the VM locale for time. 如果不希望 Azure 自动修补 SQL Server 和操作系统,请单击“禁用” 。If you do not want Azure to automatically patch SQL Server and the operating system, click Disable.

SQL 自动修补

有关详细信息,请参阅 Azure 虚拟机中 SQL Server 的自动修补For more information, see Automated Patching for SQL Server in Azure Virtual Machines.

自动备份Automated backup

在“自动备份” 下启用针对所有数据库的自动数据库备份。Enable automatic database backups for all databases under Automated backup. 默认情况下,自动备份处于禁用状态。Automated backup is disabled by default.

启用 SQL 自动备份以后,即可进行以下设置的配置:When you enable SQL automated backup, you can configure the following settings:

  • 备份保留期(天)Retention period (days) for backups
  • 用于备份的存储帐户Storage account to use for backups
  • 备份的加密选项和密码Encryption option and password for backups
  • 备份系统数据库Backup system databases
  • 配置备份计划Configure backup schedule

若要加密备份,请单击“ 启用”。To encrypt the backup, click Enable. 然后指定“密码” 。Then specify the Password. Azure 创建一个证书来加密备份,并使用指定的密码来保护该证书。Azure creates a certificate to encrypt the backups and uses the specified password to protect that certificate.

SQL 自动备份

有关详细信息,请参阅 针对 Azure 虚拟机中 SQL Server 的自动备份For more information, see Automated Backup for SQL Server in Azure Virtual Machines.

Azure Key Vault 集成Azure Key Vault integration

如果要将安全密码存储在 Azure 中进行加密,请先单击“Azure 密钥保管库集成”,并单击“启用”。 To store security secrets in Azure for encryption, click Azure key vault integration and click Enable.

SQL Azure 密钥保管库集成

下表列出了配置 Azure 密钥保管库集成所需的参数。The following table lists the parameters required to configure Azure Key Vault Integration.

参数PARAMETER 说明DESCRIPTION 示例EXAMPLE
密钥保管库 URLKey Vault URL 密钥保管库的位置。The location of the key vault. https://contosokeyvault.vault.azure.cn/https://contosokeyvault.vault.azure.cn/
主体名称Principal name Azure Active Directory 服务主体名称。Azure Active Directory service principal name. 该名称也称为客户端 ID。This name is also referred to as the Client ID. fde2b411-33d5-4e11-af04eb07b669ccf2fde2b411-33d5-4e11-af04eb07b669ccf2
主体密码Principal secret Azure Active Directory 服务主体密码。Azure Active Directory service principal secret. 该密码也称为客户端密码。This secret is also referred to as the Client Secret. 9VTJSQwzlFepD8XODnzy8n2V01Jd8dAjwm/azF1XDKM=9VTJSQwzlFepD8XODnzy8n2V01Jd8dAjwm/azF1XDKM=
凭据名称Credential name 凭据名称:AKV 集成在 SQL Server 内创建一个凭据,使 VM 具有对密钥保管库的访问权限。Credential name: AKV Integration creates a credential within SQL Server, allowing the VM to have access to the key vault. 为此凭据选择一个名称。Choose a name for this credential. mycred1mycred1

有关详细信息,请参阅 为 Azure VM 上的 SQL Server 配置 Azure 密钥保管库集成For more information, see Configure Azure Key Vault Integration for SQL Server on Azure VMs.

SQL Server 机器学习服务SQL Server Machine Learning Services

可以选择启用 SQL Server 机器学习服务You have the option to enable SQL Server Machine Learning Services. 使用此选项,可使用 SQL Server 2017 的高级分析功能。This option enables you to use advanced analytics with SQL Server 2017. 在“SQL Server 设置”窗口中单击“启用”。 Click Enable on the SQL Server Settings window.

启用 SQL Server 机器学习服务

配置完 SQL Server 设置后,单击“确定” 。When you are finished configuring SQL Server settings, click OK.

5.查看摘要5. Review the summary

在“摘要”窗口上查看摘要,并单击“确定”以创建为此 VM 指定的 SQL Server、资源组和资源。 On the Summary window, review the summary and click OK to create SQL Server, resource group, and resources specified for this VM.

可以从 Azure 门户监视部署情况。You can monitor the deployment from the Azure portal. 屏幕顶部的“通知” 按钮显示部署的基本状态。The Notifications button at the top of the screen shows basic status of the deployment.

Note

为了让你了解部署时间,我已使用默认设置将一个 SQL VM 部署到中国东部区域。To provide you with an idea on deployment times, I deployed a SQL VM to the China East region with default settings. 此测试部署花费了约 12 分钟才完成。This test deployment took approximately 12 minutes to complete. 但是根据你所在的区域和选择的设置,花费的部署时间会更长或更短。But you might experience a faster or slower deployment time based on your region and selected settings.

使用远程桌面打开 VMOpen the VM with Remote Desktop

使用以下步骤通过远程桌面连接到 SQL Server 虚拟机:Use the following steps to connect to the SQL Server virtual machine with Remote Desktop:

  1. 创建并运行 Azure 虚拟机以后,单击 Azure 门户中的“虚拟机”图标即可查看 VM。After the Azure virtual machine is created and running, click the Virtual Machines icon in the Azure portal to view your VMs.

  2. 单击对应于新建 VM 的省略号 ...。Click the ellipsis, ..., for your new VM.

  3. 单击“连接”。Click Connect.

    在门户中连接到 VM

  4. 打开浏览器为 VM 下载的 RDP 文件。Open the RDP file that your browser downloads for the VM.

  5. “远程桌面连接”会通知你,无法识别此远程连接的发布者。The Remote Desktop Connection notifies you that the publisher of this remote connection cannot be identified. 单击“ 连接 ”以继续。Click Connect to continue.

  6. 在“Windows 安全性”对话框中,单击“使用其他帐户”。In the Windows Security dialog, click Use a different account. 可能需要单击“更多选项”才能看到此项。You might have to click More choices to see this. 指定在创建 VM 时配置的用户名和密码。Specify the user name and password that you configured when you created the VM. 必须在用户名之前添加反斜杠。You must add a backslash before the user name.

    远程桌面身份验证

  7. 单击“确定”进行连接。Click OK to connect.

连接到 SQL Server 虚拟机以后,即可启动 SQL Server Management Studio 并使用本地管理员凭据通过 Windows 身份验证进行连接。After you connect to the SQL Server virtual machine, you can launch SQL Server Management Studio and connect with Windows Authentication using your local administrator credentials. 如果已启用 SQL Server 身份验证,也可以使用在预配期间配置的 SQL 登录名和密码来配合 SQL 身份验证进行连接。If you enabled SQL Server Authentication, you can also connect with SQL Authentication using the SQL login and password you configured during provisioning.

通过访问计算机,可以根据要求直接更改计算机和 SQL Server 设置。Access to the machine enables you to directly change machine and SQL Server settings based on your requirements. 例如,可以配置防火墙设置或更改 SQL Server 配置设置。For example, you could configure the firewall settings or change SQL Server configuration settings.

远程连接到 SQL ServerConnect to SQL Server remotely

在本演示中,选择了虚拟机的“公共”访问权限和“SQL Server 身份验证”。 In this walkthrough, you selected Public access for the virtual machine and SQL Server Authentication. 这些设置将虚拟机自动配置为允许任何客户端通过 Internet 来与 SQL Server 建立连接(假设这些客户端可提供正确的 SQL 登录名)。These settings automatically configured the virtual machine to allow SQL Server connections from any client over the internet (assuming they have the correct SQL login).

Note

如果没有在预配过程中选择“公共”,则可在预配后通过门户更改 SQL 连接设置。If you did not select Public during provisioning, then you can change your SQL connectivity settings through the portal after provisioning. 有关详细信息,请参阅更改 SQL 连接设置For more information, see Change your SQL connectivity settings.

以下部分说明如何通过 Internet 连接到 SQL Server VM 实例。The following sections show how to connect over the internet to your SQL Server VM instance.

配置用于公共 IP 地址的 DNS 标签Configure a DNS Label for the public IP address

若要从 Internet 连接到 SQL Server 数据库引擎,请考虑创建用于公共 IP 地址的 DNS 标签。To connect to the SQL Server Database Engine from the Internet, consider creating a DNS Label for your public IP address. 可以通过 IP 地址进行连接,但 DNS 标签可以创建更容易标识的 A 记录,并可抽象基础性公共 IP 地址。You can connect by IP address, but the DNS Label creates an A Record that is easier to identify and abstracts the underlying public IP address.

Note

如果打算只连接到同一虚拟网络中的 SQL Server 实例,或者只进行本地连接,则 DNS 标签不是必需的。DNS Labels are not required if you plan to only connect to the SQL Server instance within the same Virtual Network or only locally.

若要创建 DNS 标签,请首先在门户中选择“虚拟机” 。To create a DNS Label, first select Virtual machines in the portal. 选择要显示其属性的 SQL Server VM。Select your SQL Server VM to bring up its properties.

  1. 在虚拟机概览中,选择“公共 IP 地址”。In the virtual machine overview, select your Public IP address.

    公共 ip 地址

  2. 在公共 IP 地址的属性中,展开“配置” 。In the properties for your Public IP address, expand Configuration.

  3. 输入 DNS 标签名称。Enter a DNS Label name. 此名称是一种可通过名称而非 IP 地址直接连接到 SQL Server VM 的 A 记录。This name is an A Record that can be used to connect to your SQL Server VM by name instead of by IP Address directly.

  4. 单击“保存”按钮 。Click the Save button.

    dns 标签

从其他计算机连接到数据库引擎Connect to the Database Engine from another computer

  1. 在连接到 Internet 的计算机上,打开 SQL Server Management Studio (SSMS)。On a computer connected to the internet, open SQL Server Management Studio (SSMS). 如果没有 SQL Server Management Studio,可以从此处下载。If you do not have SQL Server Management Studio, you can download it here.

  2. 在“连接到服务器”或“连接到数据库引擎”对话框中,编辑“服务器名称”值。In the Connect to Server or Connect to Database Engine dialog box, edit the Server name value. 输入虚拟机的 IP 地址或完整 DNS 名称(已在上一个任务中确定)。Enter the IP address or full DNS name of the virtual machine (determined in the previous task). 也可添加逗号并提供 SQL Server 的 TCP 端口。You can also add a comma and provide SQL Server's TCP port. 例如,mysqlvmlabel.chinaeast.cloudapp.chinacloudapi.cn,1433For example, mysqlvmlabel.chinaeast.cloudapp.chinacloudapi.cn,1433.

  3. 在“身份验证”框中,选择“SQL Server 身份验证”。In the Authentication box, select SQL Server Authentication.

  4. 在“登录” 框中,键入有效 SQL 登录的名称。In the Login box, type the name of a valid SQL login.

  5. 在“密码” 框中,键入登录的密码。In the Password box, type the password of the login.

  6. 单击“连接” 。Click Connect.

    ssms 连接

Note

本示例使用常用端口 1433。This example uses the common port 1433. 但是,如果在部署 SQL Server VM 过程中指定了其他端口(例如 1401),则需修改此值。However, this value will need to be modified if a different port (such as 1401) was specified during the deployment of the SQL Server VM.

后续步骤Next steps

有关在 Azure 中使用 SQL Server 的其他信息,请参阅 Azure 虚拟机上的 SQL Server常见问题For other information about using SQL Server in Azure, see SQL Server on Azure Virtual Machines and the Frequently Asked Questions.