Exportera (0) Skriv ut
Visa allt
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

Tutorial: Configure and connect to a SQL Server virtual machine in a different cloud service in Azure

Updated: February 28, 2014

This tutorial demonstrates how to configure and connect multiple SQL Server virtual machines in different cloud services in Azure so that they can communicate with each other. All virtual machines that you create in Azure can automatically communicate using a private network channel with other virtual machines in the same cloud service or virtual network. However, you need to add an endpoint to a machine for other resources on the Internet or other virtual networks or other virtual machines in different cloud services to communicate with it.

When you create a virtual machine, a cloud service is automatically created to contain the machine. For simplicity, this tutorial uses the same account to create multiple virtual machines and demonstrates how to connect to a virtual machine if it is in a different cloud service. If you are planning to connect multiple virtual machines under the same account, we recommend that you place them in a private Azure Virtual Network to avoid using the Domain Name System (DNS) name of the virtual machine. For an example of how to setup a private virtual network, see Tutorial: Connect ASP.NET application to SQL Server in Azure via Virtual Network or Add a Virtual Machine to a Virtual Network.

To connect the virtual machines in different cloud services, you need to add an endpoint to the virtual machine that you want to connect to and also need to open TCP ports in the Windows Firewall for the database engine that resides in that virtual machine.

In this tutorial, you will:

Provision two SQL Server virtual machines from the gallery

  1. Before following the steps in this tutorial, create a new virtual machine, SQLVM1, as defined in the Provision two SQL Server virtual machines from the gallery section of the Tutorial: Configure and connect multiple SQL Server virtual machines in the same cloud service in Azure tutorial. If you have already SQLVM1 created, skip this step.

  2. To create an additional SQL Server virtual machine, simply follow the steps defined in the Provision two SQL Server virtual machines from the gallery section of the Tutorial: Configure and connect multiple SQL Server virtual machines in the same cloud service in Azure tutorial, except:

    1. In the Virtual machine configuration page, type SQLVM3 as a virtual machine name. Note that, in the Azure Portal, when you click a virtual machine name to open its Dashboard, you can see the virtual machine name as a host name.

      Configuration settings
    2. In the Virtual machine mode page, select Standalone Virtual Machine. Type TestSQLVM3 as a DNS name.

      VM Mode

Azure creates the virtual machine and configures the operating system settings. After Azure completes provisioning the virtual machine, it is listed as Running in the Azure Management Portal. If it is listed as Stopped, click Restart. When you create a virtual machine, a cloud service is created for you automatically. The cloud service that is created to contain this virtual machine is not shown in the Management Portal until you connect additional virtual machines to this machine. Azure defines the name of this new cloud service by using the DNS name entered in the Virtual machine mode page.

Create a TCP Endpoint for the new virtual machine

The virtual machine must have an endpoint to listen for incoming TCP communication. This Azure configuration step directs incoming TCP port traffic to a TCP port that is accessible to the virtual machine.

Each endpoint defined for a virtual machine is assigned a public and private port for communication. The private port is defined for setting up communication rules on the virtual machine and the public port is used by the Azure load balancer to communicate with the virtual machine from external sources.

  1. In the Azure Management Portal, select VIRTUAL MACHINES | SQLVM3. This opens the Dashboard for SQLVM3.

  2. Click ENDPOINTS.

  3. Click Add Endpoint. In the Add endpoint to virtual machine page, click Add Endpoint. Then, click Next.

    Add endpoint
  4. On the Specify the details of the endpoint page, type a name for the endpoint in the Name box. In the PROTOCOL box, select TCP. For example, you may type SQL Server’s default listening port 1433 in the Private Port box. Similarly, you may type 57500 in the PUBLIC PORT box. Note that many organizations select different port numbers to avoid malicious security attacks.

  5. Click the check mark to create the endpoint.

Open the virtual machine using Remote Desktop and complete setup

  1. In the Azure Management Portal, click SQLVM3 virtual machine name you created to open its Dashboard.

  2. At the bottom menu, click Connect and log in to the virtual machine using Remote Desktop (RDP). Use the Administrator credentials to log in.

  3. The first time you log on to this virtual machine, several processes may need to complete, including setup of your desktop, Windows updates, and completion of the Windows initial configuration tasks (sysprep). After Windows sysprep completes, SQL Server setup completes configuration tasks. Once you are connected to the virtual machine with Windows Remote Desktop, the virtual machine works much like any other computer. You can connect to the default instance of SQL Server with SQL Server Management Studio (running on the virtual machine) in the normal way.

  4. Close remote desktop.

Complete configuration steps to connect a SQL Server virtual machine to another SQL Server virtual machine in a different cloud service

  1. On the Azure Management Portal, click on VIRTUAL MACHINES.

  2. Connect to SQLVM3 virtual machine via Remote Desktop.

  3. You need to configure SQL Server to listen on the TCP protocol. To do this, click Start | All Programs | Microsoft SQL Server 2012 | Configuration Tools and open SQL Server Configuration Manager.

  4. In SQL Server Configuration Manager, expand SQL Server Network Configuration in the console pane.

  5. Click Protocols for instance name. (The default instance is Protocols for MSSQLSERVER).

  6. In the details pane, right-click TCP, it should be Enabled for the gallery images by default. For your custom images, click Enable (if its status is Disabled.)

  7. In the details pane, right-click SQL Server (instance name) (the default instance is SQL Server (MSSQLSERVER), and then click Restart, to stop and restart the instance of SQL Server.

  8. Then, you need to open TCP ports in the Windows firewall for the default instance of the Database Engine. To do this, click Start | All Programs | Administrative Tools, and open Windows Firewall with Advanced Security.

  9. In the Windows Firewall with Advanced Security, in the left pane, right-click Inbound Rules, and then click New Rule in the action pane.

    Windows Firewall Settings
  10. In the Rule Type dialog box, select Port, and then click Next.

  11. In the Protocol and Ports dialog box, select TCP. Select Specific local ports, and then type the port number of the instance of the Database Engine (1433 for the default instance). Click Next.

  12. In the Action dialog box, select Allow the connection, and then click Next.

  13. In the Profile dialog box, select Domain, Private, Public, and then click Next.

  14. In the Name page, set the Inbound Rule's Name to SQLServerVM3Port and click Finish. Close Windows Firewall with Advanced Security window.

    Port settings
  15. Next, you need to configure SQL Server for mixed mode authentication. The SQL Server Database Engine cannot use Windows Authentication without domain environment. To do this, click All Programs | Microsoft SQL Server 2012, and then click SQL Server Management Studio.

  16. In the Connect to Server dialog box, for the Server name, type the host name of the virtual machine to connect to the Database Engine with the Object Explorer, such as SQLVM3. Select Windows Authentication. Click Connect.

  17. In SQL Server Management Studio Object Explorer, right-click the name of the instance of SQL Server (the virtual machine name), and then click Properties.

  18. On the Security page, under Server authentication, select SQL Server and Windows Authentication mode, and then click OK.

  19. In Object Explorer, right-click your server, and then click Restart.

  20. Next, you need to create a SQL Server authentication login to connect to the first virtual machine from another computer. To do this, in SQL Server Management Studio Object Explorer, expand the SQLVM3 server instance in which you want to create the new login. Right-click the Security folder, point to New, and select Login….

  21. In the Login – New dialog box, on the General page, enter the name of the new user sqlvm3login in the Login name box. Select SQL Server authentication. In the Password box, enter a password for the new user. Enter that password again into the Confirm Password box. Leave default values in other boxes.

    Login properties

  22. On the Server Roles page, click sysadmin, if you want to designate this login as a SQL Server administrator. Click OK. By default, Azure selects Windows Authentication during SQL Server Virtual Machine setup. Therefore, the sa login is disabled and a password is assigned by setup. To use the sa login, enable it and also assign a new password. For more information, see Change Server Authentication Mode.

Connect SQL Server virtual machine to another SQL Server virtual machine in a different cloud service

To connect to a SQL Server Database Engine in a different cloud service, you must know the Domain Name System (DNS) name of the virtual machine, in which SQL Server Database Engine resides.

  1. In the Azure Management Portal, select VIRTUAL MACHINES | SQLVM3. This opens the Dashboard for SQLVM3. Copy the DNS name on the right pane, such as testsqlvm3.cloudapp.net. In addition, take a note of the public endpoint port, 57500.

  2. In the Azure Management Portal, select VIRTUAL MACHINES | SQLVM1. Click Connect button to remote desktop to the first virtual machine. Enter Administrator credentials to connect to the first virtual machine.

  3. In the first virtual machine, SQLVM1, open SQL Server Management Studio.

  4. In the Object Explorer, click Connect, choose Database Engine… In the Connect to Server dialog box, type testsqlvm3.cloudapp.net,57500 as a server name. Select SQL Server Authentication. Type sqlvm3login as a login name and enter the password you specified earlier. Click Connect.

    Connect to different cloud service
WarningWarning
When you connect to another virtual machine in a different cloud service, do not use the IP addresses that are assigned to that virtual machine. The reason is that the ip addresses might change when Azure moves resources for redundancy or maintenance. The DNS name will be stable because it can be redirected to a new IP address.

Gruppinnehåll

Visa:
© 2014 Microsoft