快速入门:配置从本地到 Azure SQL 托管实例的点到站点连接Quickstart: Configure a point-to-site connection to Azure SQL Managed Instance from on-premises

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

本快速入门演示如何使用 SQL Server Management Studio (SSMS),通过点到站点连接从本地客户端计算机连接到 Azure SQL 托管实例。This quickstart demonstrates how to connect to Azure SQL Managed Instance using SQL Server Management Studio (SSMS) from an on-premises client computer over a point-to-site connection. 有关点到站点连接的信息,请参阅关于点到站点 VPNFor information about point-to-site connections, see About Point-to-Site VPN.

先决条件Prerequisites

本快速入门:This quickstart:

将 VPN 网关连接到虚拟网络Attach a VPN gateway to a virtual network

  1. 在本地客户端计算机上打开 PowerShell。Open PowerShell on your on-premises client computer.

  2. 复制此 PowerShell 脚本。Copy this PowerShell script. 此脚本将 VPN 网关附加到在创建托管实例快速入门中创建的 SQL 托管实例虚拟网络。This script attaches a VPN gateway to the SQL Managed Instance virtual network that you created in the Create a managed instance quickstart. 此脚本使用 Azure PowerShell Az 模块,并对基于 Windows 或 Linux 的主机执行以下操作:This script uses the Azure PowerShell Az Module and does the following for either Windows or Linux-based hosts:

    • 在客户端计算机上创建并安装证书Creates and installs certificates on a client machine

    • 计算未来的 VPN 网关子网 IP 范围Calculates the future VPN gateway subnet IP range

    • 创建网关子网Creates the gateway subnet

    • 部署可将 VPN 网关附加到 VPN 子网的 Azure 资源管理器模板Deploys the Azure Resource Manager template that attaches the VPN gateway to the VPN subnet

      $scriptUrlBase = 'https://raw.githubusercontent.com/Microsoft/sql-server-samples/master/samples/manage/azure-sql-db-managed-instance/attach-vpn-gateway'
      
      $parameters = @{
        subscriptionId = '<subscriptionId>'
        resourceGroupName = '<resourceGroupName>'
        virtualNetworkName = '<virtualNetworkName>'
        certificateNamePrefix  = '<certificateNamePrefix>'
        }
      
      Invoke-Command -ScriptBlock ([Scriptblock]::Create((iwr ($scriptUrlBase+'/attachVPNGateway.ps1?t='+ [DateTime]::Now.Ticks)).Content)) -ArgumentList $parameters, $scriptUrlBase
      
  3. 在 PowerShell 窗口中粘贴脚本,并提供所需参数。Paste the script in your PowerShell window and provide the required parameters. <subscriptionId><resourceGroup><virtualNetworkName> 的值应匹配用于创建托管实例快速入门的值。The values for <subscriptionId>, <resourceGroup>, and <virtualNetworkName> should match the ones that you used for the Create a managed instance quickstart. <certificateNamePrefix> 的值可以是所选字符串。The value for <certificateNamePrefix> can be a string of your choice.

  4. 执行 PowerShell 脚本。Execute the PowerShell script.

重要

在 PowerShell 脚本完成前,请勿继续操作。Do not continue until the PowerShell script completes.

创建 VPN 连接Create a VPN connection

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 打开在其中创建了虚拟网关的资源组,然后打开虚拟网关资源。Open the resource group in which you created the virtual network gateway, and then open the virtual network gateway resource.

  3. 选择“点到站点配置”,然后选择“下载 VPN 客户端”。Select Point-to-site configuration and then select Download VPN client.

    下载 VPN 客户端

  4. 在本地客户端计算机上,从 zip 文件中提取文件,然后打开包含已提取文件的文件夹。On your on-premises client computer, extract the files from the zip file and then open the folder with the extracted files.

  5. 打开“WindowsAmd64”文件夹,然后打开“VpnClientSetupAmd64.exe”文件 。Open the WindowsAmd64 folder and open the VpnClientSetupAmd64.exe file.

  6. 如果收到“Windows 已保护你的电脑”消息,请单击“更多信息”,然后单击“仍然运行”。 If you receive a Windows protected your PC message, click More info and then click Run anyway.

    安装 VPN 客户端

  7. 在“用户帐户控制”对话框中单击“是”,继续下一步。In the User Account Control dialog box, click Yes to continue.

  8. 在引用虚拟网络的对话框中选择“是”,为虚拟网络安装 VPN 客户端。In the dialog box referencing your virtual network, select Yes to install the VPN client for your virtual network.

连接到 VPN 连接Connect to the VPN connection

  1. 在本地客户端计算机上的“网络和 Internet”中转到“VPN”,选择“SQL 托管实例”虚拟网络,以便建立到此 VNet 的连接。 Go to VPN in Network & Internet on your on-premises client computer and select your SQL Managed Instance virtual network to establish a connection to this VNet. 在下图中,VNet 名为 MyNewVNetIn the following image, the VNet is named MyNewVNet.

    VPN 连接

  2. 选择“连接” 。Select Connect.

  3. 在对话框中,选择“连接”。In the dialog box, select Connect.

    VPN 连接

  4. 当系统提示你连接管理器需要提升的特权才能更新路由表时,请选择“继续”。When you're prompted that Connection Manager needs elevated privileges to update your route table, choose Continue.

  5. 在“用户帐户控制”对话框中选择“是”,继续下一步。Select Yes in the User Account Control dialog box to continue.

    已建立与 SQL 托管实例 VNet 的 VPN 连接。You've established a VPN connection to your SQL Managed Instance VNet.

    VPN 连接

使用 SSMS 进行连接Connect with SSMS

  1. 在本地客户端计算机上,打开 SQL Server Management Studio。On the on-premises client computer, open SQL Server Management Studio.

  2. 在“连接到服务器”对话框的“服务器名称”框中,输入托管实例的完全限定主机名。 In the Connect to Server dialog box, enter the fully qualified host name for your managed instance in the Server name box.

  3. 选择“SQL Server 身份验证”,提供用户名和密码,然后选择“连接”。 Select SQL Server Authentication, provide your username and password, and then select Connect.

    SSMS 连接

连接后,可以在“数据库”节点中查看系统和用户数据库。After you connect, you can view your system and user databases in the Databases node. 还可以在“安全性”、“服务器对象”、“复制”、“管理”、“SQL Server 代理”和“XEvent 探查器”节点中查看各种对象。You can also view various objects in the Security, Server Objects, Replication, Management, SQL Server Agent, and XEvent Profiler nodes.

后续步骤Next steps