您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何在 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.

提示

如果对 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 free account before you begin.

SQL Server 虚拟机库映像SQL Server virtual machine gallery images

创建 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 门户的左侧菜单中选择“Azure SQL”。Select Azure SQL in the left-hand menu of the Azure portal. 如果AZURE sql不在列表中,请选择 "所有服务",然后在搜索框中键入 "Azure sql"。If Azure SQL is not in the list, select All services, then type Azure SQL in the search box. (可选)选择“Azure SQL”旁边的星号将其收藏并将其添加为左侧导航栏中的项。(Optional) Select the star next to Azure SQL to favorite it and add it as an item in the left-hand navigation.

  2. 选择“+ 添加”以打开“选择 SQL 部署选项”页。Select + Add to open the Select SQL deployment option page. 您可以通过选择 "显示详细信息" 查看其他信息。You can view additional information by selecting Show details.

  3. 在 " SQL 虚拟机" 磁贴上的 SQL Server 图像搜索框中键入 2017,然后选择 **Free SQL Server 许可证:SQL Server 2017 开发人员: Windows Server 2016 @ no__t-0 从下拉。Type 2017 in the SQL Server image search box on the SQL virtual machines tile, and then select Free SQL Server License: SQL Server 2017 Developer on Windows Server 2016 from the drop-down.

    选择 SQL VM 映像

    提示

    本演示使用 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.

    提示

    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.

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

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

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

  • 在 "项目详细信息" 下, 确保选择了正确的订阅。Under Project Details, make sure the correct subscription is selected.

  • 在 "资源组" 部分中, 从列表中选择现有的资源组, 或选择 "新建" 以创建新的资源组。In the Resource group section, either select an existing resource group from the list or choose Create new to create a new resource group. 资源组是 Azure(虚拟机、存储帐户、虚拟网络等)中相关资源的集合。A resource group is a collection of related resources in Azure (virtual machines, storage accounts, virtual networks, etc.).

    订阅

备注

如果只是测试或了解 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 资源管理器概述For more information about resource groups, see Azure Resource Manager Overview.

  • 在“实例详细信息”下:Under Instance details:

    1. 输入唯一的虚拟机名称Enter a unique Virtual machine name.
    2. 为“区域”选择一个位置。Choose a location for your Region.
    3. 出于本指南的目的, 请将 "可用性选项" 设置为 "无需基础结构冗余"。For the purpose of this guide, leave Availability options set to No infrastructure redundancy required. 有关可用性选项的详细信息,请参阅可用性To find out more information about availability options, see Availability.
    4. 在“映像”列表中,选择“免费 SQL Server 许可证:Windows Server 2016 上的 SQL Server 2017 Developer”的映像。In the Image list, select Free SQL Server License: SQL Server 2017 Developer on Windows Server 2016.
    5. 对于虚拟机大小,请选择“更改大小”,然后选择“A2 基本”产品/服务。Choose to Change size for the Size of the virtual machine and select the A2 Basic offering. 用完资源后,请务必清理资源,以免产生任何意外的费用。Be sure to clean up your resources once you're done with them to prevent any unexpected charges. 对于生产工作负荷,请参阅 Azure 虚拟机中 SQL Server 的性能最佳做法中建议的计算机大小和配置。For production workloads, see the recommended machine sizes and configuration in Performance best practices for SQL Server in Azure Virtual Machines.

    实例详细信息

重要

在“选择大小”窗口中显示的每月估计成本不包括 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.

  • 在 "管理员帐户" 下提供用户名和密码。Under Administrator account, provide a username and a password. 密码必须至少 12 个字符长,且符合定义的复杂性要求The password must be at least 12 characters long and meet the defined complexity requirements.

    管理员帐户

  • 在“入站端口规则”下,选择“允许所选端口”,然后从下拉列表中选择“RDP (3389)”。Under Inbound port rules, choose Allow selected ports and then select RDP (3389) from the drop-down.

    入站端口规则

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

磁盘Disks

在 "磁盘" 选项卡上, 配置磁盘选项。On the Disks tab, configure your disk options.

  • 在 " os 磁盘类型" 下, 从下拉类型中选择要用于操作系统的磁盘类型。Under OS disk type, select the type of disk you want for your OS from the drop-down. 建议为生产系统使用高级版, 但不适用于基本 VM。Premium is recommended for production systems but is not available for a Basic VM. 若要使用高级 SSD, 请更改虚拟机大小。To utilize Premium SSD, change the virtual machine size.

  • 在 "高级" 下的 "使用托管磁盘" 下选择 "是"Under Advanced, select Yes under use Managed Disks.

    备注

    Microsoft 建议为 SQL Server 使用托管磁盘。Microsoft 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 托管磁盘概述For more information, see Azure Managed Disks Overview. 有关可用性集中托管磁盘的具体信息,请参阅为可用性集中的 VM 使用托管磁盘For specifics about managed disks in an availability set, see Use managed disks for VMs in availability set.

SQL VM 磁盘设置

网络Networking

在 "网络" 选项卡上, 配置网络选项。On the Networking tab, configure your networking options.

  • 创建新的虚拟网络, 或使用现有的 vNet 作为 SQL Server VM。Create a new virtual network, or use an existing vNet for your SQL Server VM. 同时指定一个子网Designate a Subnet as well.

  • 在 " NIC 网络安全组" 下,选择 "基本" 安全组或 "高级" 安全组。Under NIC network security group, select either a basic security group, or the advanced security group. 选择 "基本" 选项后, 可以为 SQL Server VM 选择入站端口 (在 "基本" 选项卡上配置的值相同)。Choosing the basic option allows you to select inbound ports for the SQL Server VM (the same values that were configured on the Basic tab). 选择 "高级" 选项, 可以选择现有的网络安全组, 也可以创建一个新的安全组。Selecting the advanced option allows you to choose an existing network security group, or create a new one.

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

SQL VM 网络设置

监视Monitoring

在 "监视" 选项卡上, 配置监视和自动关闭。On the Monitoring tab, configure monitoring and autoshutdown.

  • 默认情况下,Azure 会启用使用为 VM 指定的同一个存储帐户的启动诊断Azure enables Boot diagnostics by default with the same storage account designated for the VM. 你可以在此处更改这些设置, 并启用OS 来宾诊断You can change these settings here, as well as enabling OS guest diagnostics.
  • 也可以在此选项卡上启用系统分配的托管标识自动关闭You can enable System assigned managed identity and autoshutdown on this tab as well.

SQL VM 管理设置

3.配置 SQL Server 设置3. 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
Azure 密钥保管库集成Azure Key Vault Integration
存储配置Storage configuration
自动修补Automated Patching
自动备份Automated Backup
R Services (高级分析)R Services (Advanced Analytics)

连接性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 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.

SQL VM 安全性

若要通过 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 身份验证, 请在SQL Server 设置"选项卡上单击" SQL 身份验证"下的"启用"。If you require SQL Server Authentication, click Enable under SQL authentication on the SQL Server settings tab.

SQL Server 身份验证

备注

如果计划通过 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.

Azure 密钥保管库集成Azure Key Vault integration

若要将安全机密存储在 Azure 中进行加密, 请选择 " SQL Server 设置", 并向下滚动到 " azure 密钥保管库集成"。To store security secrets in Azure for encryption, select SQL Server settings, and scroll down to Azure key vault integration. 选择 "启用", 并填写所需的信息。Select Enable and fill in the requested information.

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.net/https://contosokeyvault.vault.azure.net/
主体名称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.

存储配置Storage configuration

在 " SQL Server 设置" 选项卡上的 "存储配置" 下,选择 "更改配置" 以打开 "性能优化存储配置" 页,并指定存储要求。On the SQL Server settings tab, under Storage configuration, select Change configuration to open the Performance Optimized Storage Configuration page and specify the storage requirements.

SQL VM 存储配置

在“ 存储优化目标”下,选择以下选项之一: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 VM 存储配置

您可以选择将值保留为默认值,也可以根据 IOPS 需要手动更改存储拓扑。You can choose to leave the values at default, or you can manually change the storage topology to suit your IOPS needs. 有关详细信息,请参阅存储配置For more information, see storage configuration.

SQL Server 许可证SQL Server License

如果你是软件保障客户, 则可以利用Azure 混合权益来引入你自己的 SQL Server 许可证并保存资源。If you're a Software Assurance customer, you can utilize the Azure Hybrid Benefit to bring your own SQL Server license and save on resources.

SQL VM 许可证

自动修补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 VM 自动修补

有关详细信息,请参阅 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. 默认情况下会自动设置计划, 但你可以通过选择 "手动" 来创建手动计划。By default the schedule is set automatically, but you can create a manual schedule by selecting Manual.

SQL VM 自动备份

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

R Services (高级分析)R Services (Advanced Analytics)

你可以选择启用SQL Server R Services (高级分析)You have the option to enable SQL Server R Services (Advanced Analytics). 使用此选项,可使用 SQL Server 2017 的高级分析功能。This option enables you to use advanced analytics with SQL Server 2017. SQL Server 设置"窗口中选择"启用"。Select Enable on the SQL Server Settings window.

4.查看 + 创建4. Review + create

在“查看 + 创建”选项卡中查看摘要,然后选择“创建”以创建为此 VM 指定的 SQL Server、资源组和资源。On the Review + create tab, review the summary, and select Create 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.

备注

为了让你了解部署时间,我已使用默认设置将一个 SQL VM 部署到美国东部区域。To provide you with an idea on deployment times, I deployed a SQL VM to the East US 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).

备注

如果没有在预配过程中选择“公共”,则可在预配后通过门户更改 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.

备注

如果打算只连接到同一虚拟网络中的 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.eastus.cloudapp.azure.com,1433For example, mysqlvmlabel.eastus.cloudapp.azure.com,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 连接

备注

本示例使用常用端口 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.