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

本快速入门演示如何使用本地客户端计算机的点到站点连接,通过 SQL Server Management Studio (SSMS) 连接到 Azure SQL 数据库托管实例。This quickstart demonstrates how to connect to an Azure SQL Database 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 your Managed Instance virtual network

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

  2. 复制此 PowerShell 脚本。Copy this PowerShell script. 此脚本将 VPN 网关附加到在创建托管实例快速入门中创建的托管实例虚拟网络。This script attaches a VPN Gateway to the 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 will do the following for either Windows or Linux based hosts:

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

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

    • 创建 GatewaySubnetCreates the GatewaySubnet

    • 部署可将 VPN 网关附加到 VPN 子网的 Azure 资源管理器模板Deploys the Azure Resource Manager template that attaches the VPN Gateway to 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 Managed Instance quickstart. <certificateNamePrefix> 的值可以是所选字符串。The value for <certificateNamePrefix> can be a string of your choice.

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

Important

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

创建连接到托管实例的 VPN 连接Create a VPN connection to your Managed Instance

  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”,选择“托管实例”虚拟网络,以便建立到此 VNet 的连接。 Go to VPN in Network & Internet on your on-premises client computer and select your 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 prompted that Connection Manager needs elevated privilege to update your route table, choose Continue.

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

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

    VPN 连接

使用 SSMS 连接到托管实例Use SSMS to connect to the Managed Instance

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

  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 Profiler 节点中查看各种对象。You can also view various objects in the Security, Server Objects, Replication, Management, SQL Server Agent, and XEvent Profiler nodes.

后续步骤Next steps