Installing Web Server Role on a Virtual Machine
Tags: virtualmachine, webserverrole, azureportal
Published: 2023-05-14 12:59:01

A virtual machine is a digital equivalent of a physical computer. It can perform all functions that a physical computer can perform. These include running programs and operating systems, storing data, connecting to networks etc. It requires upkeep such as updates and system monitoring just like the physical computer.

Lets quickly run through how to create one, then we will connect to it and install a server role on the Virtual machine.

1.<u>Create a Virtual Machine</u>
a)Log in to Azure Portal and select Virtual Machine

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xieuc2g63byunkdgfkos.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r0uisn2zkjihqwww33jy.png)


b)Click on Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9t9sf4yk125ah2hx2fk.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gmorr4w23w6k35gs1bbn.png)



c)Complete the following fields:
Subscription, Resource group(I will create MayWorkload1), Virtual Machine Name(Give the Virtual Machine a name, I will name this one Abby), Region(Select a Region of your choice) and Availability zone

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8hx1p3h72nz6vqs99xm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbrfxwm06zkn9bxjykan.png)






Select Windows for the VM Image 
Leave Security type, VM Architecture and Size at default

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/naf8tbnk7dhca8qo94fk.png)


Under Administrator Account, Create User Name and Password
For this demo, our username is Azureuser and the password is Password123*
Note that these are the log in details for the Virtual Machine
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfip51158pbuv32eu778.png)
Inbound Port Rules: Select HTTP 80 and RDP

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p1dlq28uha342zrkd3qr.png)


Go to Monitoring and disable Diagnostics

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5301ninp2uyohmofc128.png)


d)Click on Review and Create

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rldzt0ay2bkugq27v5gz.png)


If Validation is passed, click on Create and if not, check to fix any error detected and move on

e)When the VM is fully deployed, click on Go to Resource. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmii767bet441asxfquj.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okeswzzt71kghn8eap77.png)



2.<u>Connect to the Virtual Machine</u>
a)Click on Connect and select RDP

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6as7n93v2zc6lbnn563.png)


b)Click on Download RDP Files and open the file downloaded

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ir8h7eyyqnix0znjxvco.png)


A Window for the Remote Desktop Connection will come up.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bvbyautn9sgjr5oordn.png)


c)Click on Connect and enter the User name and Password created in Step 1(c) above

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6s5viw0en9rqr6yzyz75.png)


d)Click OK
The Virtual Machine is ready

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/msglklvvlbnp9jhcuvvk.jpg)

3.<u>Install a Web Server role using PowerShell</u>
a)On the desktop of the VM, use the Search window to search for Windows PowerShell. Click on it and select Run as Administrator

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8uw73y18a90er3nosokl.jpg)

b)When the Terminal is ready, type this command in front of the Username:  **Install-WindowsFeature Web-Server**
Type in this command exactly as it appears here because the PowerShell terminal window is case sensitive

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lo1q5ygnagnm8iu2jjmj.jpg)


Then press enter to allow it to install the Web Server
When the Web server has been fully installed, it will show Success as seen in the Image below

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qxowcj0tj22qh4e7n82p.jpg)


d)Go to the Overview page of the VM on the Azure portal and copy the Public IP Address of the VM.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/012b0yg7bwvbp19y7oqx.png)


Place it in your web browser to test the web server installed

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rug6yqj09eyphlwtnp1z.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ws2i6lq4gca4euftltrs.png)


You can see that we have successfully install a web server role on the Virtual Machine

I will like to have your feedbacks if you find this piece helpful