Virtual Machine Running Windows Server

Download Report

Transcript Virtual Machine Running Windows Server

Virtual Machine
 A virtual machine in Windows Azure is a server in the
cloud that one can control and manage. After a virtual
machine is created in Windows Azure, you can delete
and re-create it whenever you need to.
 It can be accessed just like any other server.
 Virtual hard disks (.vhd files) are used to create a
virtual machine.
 You can use the following types of virtual hard disks to
create a virtual machine
Virtual Machine
 Image - An image is a template that you use to create a
new virtual machine. An image doesn’t have specific
settings like a running virtual machine, such as the
computer name and user account settings.
 If you use an image to create a virtual machine, an
operating system disk is automatically created for the
new virtual machine.
Virtual Machine
 Disk - A disk is a VHD that you can boot and mount as
a running version of an operating system. After an
image is provisioned, it becomes a disk.
 A disk is always created when you use an image to
create a virtual machine.
 Any VHD that is attached to virtualized hardware and
that is running as part of a service is a disk.
Virtual Machine
 You can use the following options to create a virtual
machine from an image:
 Create a virtual machine by using a platform image
available from the Windows Azure Management
Portal.
 Create and upload a .vhd file that contains an image to
Windows Azure, and then use the uploaded image to
create a virtual machine.
Virtual Machine
 Each virtual machine resides in a cloud service, either
by itself, or grouped with other virtual machines.
 You can place virtual machines in the same cloud
service to enable the virtual machines to communicate
with each other, to load-balance network traffic
among virtual machines, and to maintain high
availability of the machines.
Virtual Machine
 How to create the virtual machine
 One can create a virtual machine From Gallery
method in the Management Portal to create a custom
virtual machine.
 This method provides more options than the Quick
Create method does for configuring the virtual
machine when you create it, such as the connected
resources, the DNS name, and the network
connectivity if needed.
Virtual Machine
 1.Sign in to the Windows Azure Management Portal.
 2.On the command bar, click New.
 3.Click Virtual Machine, and then click From
Gallery.
 4.Click Platform Images, select one of the images,
and then click the arrow to continue.
Virtual Machine
 5.If multiple versions of the image are available, in
Version Release Date, pick the version you want to
use.
 6.In Virtual Machine Name, type the name that you
want to use for the virtual machine. For this virtual
machine, type MyTestVM1.
 7.In Size, select the size of the virtual machine. The
size you should select depends on the number of cores
required to run your application. For this virtual
machine, choose the smallest available size.
Virtual Machine
 8.In New User Name, type a name for the
administrative account that you want to use to manage
the server. For this virtual machine, type
MyTestVM1Admin.
 9.In New Password, type a strong password for the
administrative account on the virtual machine. In
Confirm Password, retype the password.
 10.Click the arrow to continue.
Virtual Machine
 1.You can place virtual machines together under a
cloud service to provide robust applications, but for
this tutorial, you only create a single virtual machine.
To do this, select Create a new cloud service.
 2.In Cloud Service DNS Name, type a name that uses
between 3 and 24 lowercase letters and numbers. This
name becomes part of the URI that is used to contact
the virtual machine through the cloud service. For this
virtual machine, type MyService1.
Virtual Machine
 3.In Region/Affinity Group/Virtual Network, select
where you want to locate the virtual machine.
 4.You can select a storage account where the VHD file
is stored. For this tutorial, accept the default setting of
Use an Automatically Generated Storage Account.
 5.Under Availability Set, for the purposes of this
tutorial use the default setting of None.
Virtual Machine
 6.Click the arrow to continue.
 7.Under Endpoints, new endpoints are created to allow
connections for Remote Desktop and Windows
PowerShell remoting. (Endpoints allow resources on
the Internet or other virtual networks to communicate
with a virtual machine.) You can add more endpoints
now, or create them later.
 8.Click the check mark to create the virtual machine.
Virtual Machine
 After the virtual machine and cloud service are
created, the Management Portal lists the new virtual
machine under Virtual Machines and lists the cloud
service under Cloud Services.
 Both the virtual machine and the cloud service are
started automatically.
Virtual Machine
Virtual Machine
 How to log on to the virtual machine after you create it
 You can log on to the virtual machine that you created to
manage both its settings and the applications that are
running on it.
 1.Sign in to the Windows Azure Management Portal.
 2.Click Virtual Machines, and then select the MyTestVM1
virtual machine.
Virtual Machine
 3.On the command bar, click Connect.
Virtual Machine
 4.Click Open to use the remote desktop protocol file
that was automatically created for the virtual machine.
 5.Click Connect.
Virtual Machine
Virtual Machine
 6.In the password box, type the user name and
password that you specified when you created the
virtual machine, and then click OK.
 7.Click Yes to verify the identity of the virtual
machine.
Virtual Machine
Virtual Machine
 You can now work with the virtual machine just like
you would a server in your office.
Virtual Machine
 How to attach a data disk to the new virtual
machine
 Your application might need to store data. To set this
up, attach a data disk to the virtual machine. The
easiest way to do this is to attach an empty data disk to
the virtual machine.
Virtual Machine
 1.Sign in to the Windows Azure Management Portal.
 2.Click Virtual Machines, and then select the
MyTestVM1 virtual machine.
 3.On the command bar, click Attach, and then click
Attach Empty Disk.
Virtual Machine
 The Attach Empty Disk dialog box appears.
Virtual Machine
 4.The Virtual Machine Name, Storage Location,
File Name, and Host Cache Preference are already
defined for you. All you have to do is enter the size that
you want for the disk. Type 5 in the Size field.
 Note: All disks are created from a VHD file in
Windows Azure storage. You can provide a name for
the VHD file that is added to storage, but Windows
Azure generates the name of the disk automatically.
Virtual Machine
 5.Click the check mark to attach the data disk to the
virtual machine.
 6.Click the name of the virtual machine. This displays
the dashboard so you can verify that the data disk was
successfully attached to the virtual machine.
 The virtual machine now has 2 disks. The disk that you
attached is listed in the Disks table.
Virtual Machine
Virtual Machine
 After you attach the data disk to the virtual machine,
the disk is offline and not initialized. Before you can
use it to store data, you'll need to log on to the virtual
machine and initialize the disk.
Virtual Machine
 1.Connect to the virtual machine by using the steps in
the previous section, How to log on to the virtual
machine after you create it.
 2.After you log on to the virtual machine, open Server
Manager. In the left pane, expand Storage, and then
click Disk Management.
 3.Right-click Disk 2, and then click Initialize Disk.
 4.Click OK to start the initialization process.
 5.Right-click the space allocation area for Disk 2, click
New Simple Volume, and then finish the wizard with
the default values.
 The disk is now online and ready to use with a new
drive letter.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Create a TCP endpoint for the virtual machine.
 The virtual machine must have an endpoint to listen for
incoming TCP communication. This Windows Azure
configuration step, directs incoming TCP port traffic to a
TCP port that is accessible to the virtual machine.
1.
2.
3.
On the Windows Azure Management Portal, click
on VIRTUAL MACHINES.
Click on your newly created virtual machine. Information
about your virtual machine is presented.
Near the top of the page, select the ENDPOINTS page, and
then at the bottom of the page, click ADD.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 On the Add Standalone Endpoint to Virtual
Machine page, click Add Endpoint, and then click
the Next arrow to continue.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 On the Specify the details of the endpoint page,
provide the following information.
 In the NAME box, provide a name for the endpoint.
 In the PROTOCOL box, select TCP. You may type SQL
Server’s default listening port 1433 in the Private
Portbox. Similarly, you may type 57500 in the PUBLIC
PORT box. Note that many organizations select
different port numbers to avoid malicious security
attacks.
 Click the check mark to continue. The endpoint is
created.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Click the check mark to continue. The endpoint is created.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Open TCP ports in the Windows firewall for the
default instance of the Database Engine
 Connect to the virtual machine via Windows Remote
Desktop. Once logged in, on the Start menu,
click Run, typeWF.msc, and then click OK.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Windows Firewall with Advanced Security,
in the left pane, right-click Inbound Rules, and then
click New Rulein the action pane.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Rule Type dialog box, select Port, and then
click Next.
 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 or your choice for the
private port in the endpoint step).
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Click Next.
 In
the Action dialog box, select Allow the
connection, and then click Next.
 Security Note: Selecting Allow the connection if it
is secure can provide additional security. Select this
option if you want to configure additional security
options in your environment.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Profile dialog box, select Public, and then
click Next.
 Security Note: Selecting Public allows access over the
internet. Whenever possible, select a more restrictive
profile.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Name dialog box, type a name and description
for this rule, and then click Finish.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Configure SQL Server to listen on the TCP protocol
 While connected to the virtual machine by using
Remote Desktop, on the Start menu, click All
Programs,
clickMicrosoft
SQL
Serverversion,
click Configuration Tools, and then click SQL Server
Configuration Manager.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In SQL Server Configuration Manager, in the console
pane, expand SQL Server Network Configuration.
 In the console pane, click Protocols for instance
name. (The default instance is Protocols for
MSSQLSERVER.)
 In the details pane, right-click TCP, it should be
Enabled for the gallery images by default. For your
custom images, clickEnable (if its status is Disabled.)
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the console pane, click SQL Server Services.
(Restarting the Database Engine can be postponed
until completion of the next step.)
 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.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Close SQL Server Configuration Manager.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 The SQL Server Database Engine cannot use Windows
Authentication without domain environment.
 To connect to the Database Engine from another
computer, configure SQL Server for mixed mode
authentication.
 Mixed mode authentication allows both SQL Server
Authentication and Windows Authentication.
(Configuring mixed mode authentication might not be
necessary if you have configured a Windows Azure
Virtual Network.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 While connected to the virtual machine by using
Remote Desktop, on the Start menu, click All
Programs, clickMicrosoft SQL Server version, and
then click SQL Server Management Studio.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 While connected to the virtual machine by using
Remote Desktop, on the Start menu, click All
Programs, clickMicrosoft SQL Server version, and
then click SQL Server Management Studio.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 The first time you open Management Studio it must
create the users Management Studio environment.
This may take a few moments.
 When opening, Management Studio presents
the Connect to Server dialog box. In the Server
name box, type the name of the virtual machine to
connect to the Database Engine with the Object
Explorer. (Instead of the virtual machine name you can
also use (local) or a single period as the Server name.
Select
Windows
Authentication,
and
leaveyourVMname\yourlocaladministrator
in
the User name box. Click Connect.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 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.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 On the Security page, under Server authentication,
select SQL Server and Windows Authentication
mode, and then click OK.

Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the SQL Server Management Studio dialog box,
click OK to acknowledge the requirement to restart
SQL Server.
 In Object Explorer, right-click your server, and then
click Restart. (If SQL Server Agent is running, it must
also be restarted.)
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the SQL Server Management Studio dialog box,
click Yes to agree that you want to restart SQL Server.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Create SQL Server authentication logins
 To connect to the Database Engine from another
computer, you must create at least one SQL Server
authentication login.
 In SQL Server Management Studio Object Explorer,
expand the folder of the server instance in which you
want to create the new login.
 Right-click the Security folder, point to New, and
select Login….
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Login – New dialog box, on the General page,
enter the name of the new user 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.
 To enforce password policy options for complexity and
enforcement,
select
Enforce
password
policy (recommended). This is a default option when
SQL Server authentication is selected.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 To enforce password policy options for expiration,
select Enforce password expiration (recommended).
Enforce password policy must be selected to enable this
checkbox. This is a default option when SQL Server
authentication is selected.
 To force the user to create a new password after the first
time the login is used, select User must change password
at next login (Recommended if this login is for someone
else to use. If the login is for your own use, do not select
this option.) Enforce password expiration must be selected
to enable this checkbox. This is a default option when SQL
Server authentication is selected.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 From the Default database list, select a default
database for the login. master is the default for this
option. If you have not yet created a user database,
leave this set to master.
 In the Default language list, leave default as the
value.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 If this is the first login you are creating, you may want
to designate this login as a SQL Server administrator. If
so, on theServer Roles page, check sysadmin.
 Security Note: Members of the sysadmin fixed server
role have complete control of the Database Engine.
You should carefully restrict membership in this role.

Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Click OK.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Determine the DNS name of the virtual machine
 To connect to the SQL Server Database Engine from
another computer, you must know the Domain Name
System (DNS) name of the virtual machine. (This is
the name the internet uses to identify the virtual
machine. You can use the IP address, but the IP
address might change when Windows Azure moves
resources for redundancy or maintenance. The DNS
name will be stable because it can be redirected to a
new IP address.)
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Windows Azure Management Portal (or from
the previous step), select VIRTUAL MACHINES.
 On the VIRTUAL MACHINE INSTANCES page, in
the DNS NAME column, find and copy the DNS name
for the virtual machine which appears preceded
by http://. (The user interface might not display the
entire name, but you can right-click on it, and select
copy.)
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Connect to the Database Engine from another
computer
 On a computer connected to the internet, open SQL
Server Management Studio.
 In the Connect to Server or Connect to Database
Engine dialog box, in the Server name box, enter the
DNS name of the virtual machine (determined in the
previous task) and a public endpoint port number in
the
format
ofDNSName,portnumber
such
as tutorialtestVM.cloudapp.net,57500.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 In the Authentication box, select SQL Server
Authentication.
 In the Login box, type the name of a login that you
created in an earlier task.
 In the Password box, type the password of the login
that you create in an earlier task.
 Click Connect.
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Configuration steps to connect to the virtual
machine Using SSMS on another computer
 Example Program to connect to SQL database engine
running on Windows Azure Virtual Machine
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Data.SqlClient;
System.Data;
Configuration steps to connect to the virtual
machine Using SSMS on another computer
namespace DBConsoleApp
{
class Program
{
private static string userName = "sa";
private static string password =
"mani@0755";
private static string dataSource =
"myvm1service.cloudapp.net,57500";
private static string
sampleDatabaseName = "ContactsDB";
Configuration steps to connect to the virtual
machine Using SSMS on another computer
static void Main(string[] args)
{
SqlConnectionStringBuilder
connString1Builder;
connString1Builder = new
SqlConnectionStringBuilder();
connString1Builder.DataSource =
dataSource;
connString1Builder.InitialCatalog =
"ContactsDB";
connString1Builder.Encrypt = true;
connString1Builder.
TrustServerCertificate = true;
connString1Builder.UserID = userName;
connString1Builder.Password = password;
Configuration steps to connect to the virtual
machine Using SSMS on another computer
using (SqlConnection conn = new
SqlConnection(connString1Builder.ToString()))
{
using (SqlCommand command =
conn.CreateCommand())
{
conn.Open();
command.CommandText =
"SELECT * FROM contacts";
Configuration steps to connect to the virtual
machine Using SSMS on another computer
using (SqlDataReader reader =
command.ExecuteReader())
{
// Loop over the results
while (reader.Read())
{
Console.WriteLine("{0},{1},
{2}, {3}",
reader["ID"].ToString().Trim(),
reader["FirstName"].ToString().Trim(),
reader["LastName"].ToString().Trim(),
reader["ContactNumber"].ToString().Trim());
}
}
Configuration steps to connect to the virtual
machine Using SSMS on another computer
Console.ReadKey();
conn.Close();
}
}
}
}
}