Virtual Machine A virtual machine in Windows Azure is a server in the cloud that one can control and...
97
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
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
Slide 3
Virtual Machine Image - An image is a template that you use to
create a new virtual machine. An image doesnt 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.
Slide 4
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.
Slide 5
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.
Slide 6
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.
Slide 7
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.
Slide 8
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.
Slide 9
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.
Slide 10
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.
Slide 11
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.
Slide 12
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.
Slide 13
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.
Slide 14
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.
Slide 15
Virtual Machine
Slide 16
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.
Slide 17
Virtual Machine 3.On the command bar, click Connect.
Slide 18
Virtual Machine 4.Click Open to use the remote desktop protocol
file that was automatically created for the virtual machine.
5.Click Connect.
Slide 19
Virtual Machine
Slide 20
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.
Slide 21
Virtual Machine
Slide 22
You can now work with the virtual machine just like you would a
server in your office.
Slide 23
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.
Slide 24
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.
Slide 25
Virtual Machine The Attach Empty Disk dialog box appears.
Slide 26
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.
Slide 27
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.
Slide 28
Virtual Machine
Slide 29
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.
Slide 30
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.
Slide 31
Slide 32
3.Right-click Disk 2, and then click Initialize Disk.
Slide 33
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.
Slide 34
Slide 35
The disk is now online and ready to use with a new drive
letter.
Slide 36
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. On the Windows Azure Management Portal,
click on VIRTUAL MACHINES. 2. Click on your newly created virtual
machine. Information about your virtual machine is presented. 3.
Near the top of the page, select the ENDPOINTS page, and then at
the bottom of the page, click ADD.
Slide 37
Slide 38
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.
Slide 39
Slide 40
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 Servers 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.
Slide 41
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 42
Click the check mark to continue. The endpoint is created.
Slide 43
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 44
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.
Slide 45
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 46
In the Windows Firewall with Advanced Security, in the left
pane, right-click Inbound Rules, and then click New Rulein the
action pane.
Slide 47
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 48
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).
Slide 49
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 50
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.
Slide 51
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 52
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.
Slide 53
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 54
In the Name dialog box, type a name and description for this
rule, and then click Finish.
Slide 55
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 56
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.
Slide 57
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 58
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.)
Slide 59
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 60
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.
Slide 61
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 62
Close SQL Server Configuration Manager.
Slide 63
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.
Slide 64
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.
Slide 65
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.
Slide 66
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 67
Slide 68
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.
Slide 69
Slide 70
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.
Slide 71
Slide 72
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.
Slide 73
Slide 74
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.)
Slide 75
Slide 76
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.
Slide 77
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.
Slide 78
Slide 79
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.
Slide 80
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.
Slide 81
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.
Slide 82
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 83
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.
Slide 84
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 85
Click OK.
Slide 86
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.)
Slide 87
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.)
Slide 88
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 89
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.
Slide 90
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.
Slide 91
Configuration steps to connect to the virtual machine Using
SSMS on another computer
Slide 92
Example Program to connect to SQL database engine running on
Windows Azure Virtual Machine using System; using
System.Collections.Generic; using System.Linq; using System.Text;
using System.Threading.Tasks; using System.Data.SqlClient; using
System.Data;
Slide 93
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";
Slide 94
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;
Slide 95
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";
Slide 96
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()); }
Slide 97
Configuration steps to connect to the virtual machine Using
SSMS on another computer Console.ReadKey(); conn.Close(); }