快速入門:設定 Azure VM 以連接到 Azure SQL 受控執行個體Quickstart: Configure an Azure VM to connect to Azure SQL Managed Instance

適用於: yesAzure SQL 受控執行個體APPLIES TO: yesAzure SQL Managed Instance

本快速入門說明如何設定 Azure 虛擬機器,以使用 SQL Server Management Studio (SSMS)連線到 Azure SQL 受控執行個體。This quickstart shows you how to configure an Azure virtual machine to connect to Azure SQL Managed Instance using SQL Server Management Studio (SSMS).

如需示範如何改為使用點對站連線從內部部署用戶端電腦連接的快速入門,請參閱設定點對站連線。For a quickstart showing how to connect from an on-premises client computer using a point-to-site connection instead, see Configure a point-to-site connection.

先決條件Prerequisites

本快速入門會使用在建立受控實例中建立的資源作為起點。This quickstart uses the resources created in Create a managed instance as its starting point.

登入 Azure 入口網站Sign in to the Azure portal

登入 Azure 入口網站Sign in to the Azure portal.

建立新的子網 VNetCreate a new subnet VNet

下列步驟會在 SQL 受控執行個體 VNet 中建立新的子網,讓 Azure 虛擬機器可以連線到受控實例。The following steps create a new subnet in the SQL Managed Instance VNet so an Azure virtual machine can connect to the managed instance. SQL 受控執行個體子網專門用於受控實例。The SQL Managed Instance subnet is dedicated to managed instances. 您無法在該子網路中建立 Azure 虛擬機器等其他資源。You can't create any other resources, like Azure virtual machines, in that subnet.

  1. 開啟您在建立受控實例快速入門中建立之受控實例的資源群組。Open the resource group for the managed instance that you created in the Create a managed instance quickstart. 選取受控實例的虛擬網路。Select the virtual network for your managed instance.

    SQL 受控執行個體資源

  2. 選取 [子網路]****,然後選取 [+ 子網路]**** 來建立新的子網路。Select Subnets and then select + Subnet to create a new subnet.

    SQL 受控執行個體子網

  3. 使用此資料表中的資訊填妥表單:Fill out the form using the information in this table:

    設定Setting 建議的值Suggested value 描述Description
    名稱Name 任何有效名稱Any valid name 如需有效的名稱,請參閱命名規則和限制For valid names, see Naming rules and restrictions.
    位址範圍 (CIDR 區塊)Address range (CIDR block) 有效範圍A valid range 針對此快速入門,使用預設值即可。The default value is good for this quickstart.
    網路安全性群組Network security group NoneNone 針對此快速入門,使用預設值即可。The default value is good for this quickstart.
    路由表Route table NoneNone 針對此快速入門,使用預設值即可。The default value is good for this quickstart.
    服務端點Service endpoints 0 (已選取)0 selected 針對此快速入門,使用預設值即可。The default value is good for this quickstart.
    子網委派Subnet delegation NoneNone 針對此快速入門,使用預設值即可。The default value is good for this quickstart.

    用戶端 VM 的新 SQL 受控執行個體子網

  4. 選取 [確定] ,在 SQL 受控執行個體 VNet 中建立這個額外的子網。Select OK to create this additional subnet in the SQL Managed Instance VNet.

在新的子網中建立 VMCreate a VM in the new subnet

下列步驟示範如何在新的子網中建立虛擬機器,以連接到 SQL 受控執行個體。The following steps show you how to create a virtual machine in the new subnet to connect to SQL Managed Instance.

準備 Azure 虛擬機器Prepare the Azure virtual machine

由於 SQL 受控執行個體放在您的私用虛擬網路中,因此您必須使用已安裝的 SQL 用戶端工具(例如 SQL Server Management Studio 或 Azure Data Studio)來建立 Azure VM。Since SQL Managed Instance is placed in your private virtual network, you need to create an Azure VM with an installed SQL client tool, like SQL Server Management Studio or Azure Data Studio. 此工具可讓您連接到 SQL 受控執行個體並執行查詢。This tool lets you connect to SQL Managed Instance and execute queries. 此快速入門使用 SQL Server Management Studio。This quickstart uses SQL Server Management Studio.

要使用所有的必要工具建立用戶端虛擬機器,最簡單的方式是使用 Azure Resource Manager 範本。The easiest way to create a client virtual machine with all necessary tools is to use the Azure Resource Manager templates.

  1. 請確定您已在另一個瀏覽器索引標籤中登入 Azure 入口網站。然後,選取下列按鈕以建立用戶端虛擬機器,並安裝 SQL Server Management Studio:Make sure that you're signed in to the Azure portal in another browser tab. Then, select the following button to create a client virtual machine and install SQL Server Management Studio:

    顯示標示為「部署至 Azure」之按鈕的影像。Image showing a button labeled "Deploy to Azure".

  2. 使用下表中的資訊填妥表單:Fill out the form using the information in the following table:

    設定Setting 建議的值Suggested value 描述Description
    訂用帳戶Subscription 有效的訂用帳戶A valid subscription 必須是您有權限在其中建立新資源的訂用帳戶。Must be a subscription in which you have permission to create new resources.
    資源群組Resource Group 您在建立 SQL 受控執行個體快速入門中所指定的資源群組The resource group that you specified in the Create SQL Managed Instance quickstart 此資源群組必須是 VNet 所在的資源群組。This resource group must be the one in which the VNet exists.
    位置Location 資源群組的位置The location for the resource group 根據選取的資源群組填入此值。This value is populated based on the resource group selected.
    虛擬機器名稱Virtual machine name 任何有效名稱Any valid name 如需有效的名稱,請參閱命名規則和限制For valid names, see Naming rules and restrictions.
    管理員使用者名稱Admin Username 任何有效的使用者名稱Any valid username 如需有效的名稱,請參閱命名規則和限制For valid names, see Naming rules and restrictions. 請勿使用 "serveradmin",因為這是保留的伺服器層級角色。Don't use "serveradmin" as that is a reserved server-level role.
    您隨時要連線至 VM 時,都可以使用這個使用者名稱。You use this username any time you connect to the VM.
    密碼Password 任何有效密碼Any valid password 密碼長度至少必須有 12 個字元,而且符合定義的複雜度需求The password must be at least 12 characters long and meet the defined complexity requirements.
    您隨時要連線至 VM 時,都可以使用這個密碼。You use this password any time you connect to the VM.
    虛擬機器大小Virtual Machine Size 任何有效大小Any valid size 在此快速入門中,使用此範本的預設值 Standard_B2s 就已足夠。The default in this template of Standard_B2s is sufficient for this quickstart.
    位置Location [resourceGroup().location]。[resourceGroup().location]. 請勿變更此值。Don't change this value.
    虛擬網路名稱Virtual Network Name 您在其中建立受控實例的虛擬網路The virtual network in which you created the managed instance
    子網路名稱Subnet name 您在上一個程序中建立的子網路名稱The name of the subnet that you created in the previous procedure 請勿選擇您在其中建立受控實例的子網。Don't choose the subnet in which you created the managed instance.
    成品位置artifacts Location [deployment().properties.templateLink.uri][deployment().properties.templateLink.uri] 請勿變更此值。Don't change this value.
    構件位置 Sas 權杖artifacts Location Sas token 保留空白Leave blank 請勿變更此值。Don't change this value.

    建立用戶端 VM

    如果您在建立 SQL 受控執行個體中使用建議的 VNet 名稱和預設子網,則不需要變更最後兩個參數。If you used the suggested VNet name and the default subnet in creating your SQL Managed Instance, you don't need to change last two parameters. 否則,您應該將這些值變更為您在設定網路環境時輸入的值。Otherwise you should change these values to the values that you entered when you set up the network environment.

  3. 選取 [我同意上方所述的條款及條件]**** 核取方塊。Select the I agree to the terms and conditions stated above checkbox.

  4. 選取 [購買]**** 以在您的網路中部署 Azure VM。Select Purchase to deploy the Azure VM in your network.

  5. 選取 [通知]**** 圖示以檢視部署的狀態。Select the Notifications icon to view the status of deployment.

重要

在虛擬機器建立大約 15 分鐘之前請不要繼續,讓建立後指令碼有時間可以安裝 SQL Server Management Studio。Do not continue until approximately 15 minutes after the virtual machine is created to give time for the post-creation scripts to install SQL Server Management Studio.

連接至虛擬機器Connect to the virtual machine

下列步驟說明如何使用遠端桌面連線來連線到新建立的虛擬機器。The following steps show you how to connect to your newly created virtual machine using a Remote Desktop connection.

  1. 部署完成之後,請移至虛擬機器資源。After deployment completes, go to the virtual machine resource.

    VM

  2. 選取 [連接]。Select Connect.

    將顯示遠端桌面通訊協定檔案 (.rdp 檔案) 表單,其中包含虛擬機器的公用 IP 位址與連接埠號碼。A Remote Desktop Protocol file (.rdp file) form appears with the public IP address and port number for the virtual machine.

    RDP 表單

  3. 選取 [下載 RDP 檔案]。Select Download RDP File.

    注意

    您也可以使用 SSH 來連線到您的 VM。You can also use SSH to connect to your VM.

  4. 關閉連線至虛擬機器表單。Close the Connect to virtual machine form.

  5. 若要連線至您的 VM,請開啟下載的 RDP 檔案。To connect to your VM, open the downloaded RDP file.

  6. 出現提示時,請選取 [連接]****。When prompted, select Connect. 在 Mac 上,您需要 RDP 用戶端,例如來自 Mac App Store 的遠端桌面用戶端On a Mac, you need an RDP client such as this Remote Desktop Client from the Mac App Store.

  7. 輸入您在建立虛擬機器時指定的使用者名稱和密碼,然後選擇 [確定]Enter the username and password you specified when creating the virtual machine, and then choose OK.

  8. 您可能會在登入過程中收到憑證警告。You might receive a certificate warning during the sign-in process. 選擇 [是]**** 或 [繼續]**** 以繼續進行連線。Choose Yes or Continue to proceed with the connection.

您已連線到 [伺服器管理員] 儀表板中的虛擬機器。You're connected to your virtual machine in the Server Manager dashboard.

連線到 SQL 受控執行個體Connect to SQL Managed Instance

  1. 在虛擬機器中,開啟 SQL Server Management Studio]。In the virtual machine, open SQL Server Management Studio.

    這需要幾分鐘的時間才能開啟,因為這是第一次啟動 SSMS 時,必須完成其設定。It takes a few moments to open, as it needs to complete its configuration since this is the first time SSMS has been started.

  2. 在 [連接到伺服器] 對話方塊的 [伺服器名稱] 方塊中,輸入受控實例的完整主機名稱In the Connect to Server dialog box, enter the fully qualified host name for your managed instance in the Server name box. 選取 [SQL Server 驗證]****,提供您的使用者名稱和密碼,然後選取 [連線]****。Select SQL Server Authentication, provide your username and password, and then select Connect.

    SSMS connect

連線之後,您可以檢視 [資料庫] 節點中的系統和使用者資料庫,以及 [安全性]、[伺服器物件]、[複寫]、[管理]、[SQL Server 代理程式] 和 [XEvent Profiler] 節點中的各種物件。After you connect, you can view your system and user databases in the Databases node, and various objects in the Security, Server Objects, Replication, Management, SQL Server Agent, and XEvent Profiler nodes.

後續步驟Next steps