Adding Data Disk to a Virtual Machine
Tags: datadisk, manageddisk, virtualmachine, cloudadministratorrole
Published: 2023-06-29 12:09:29

Creating and deploying Virtual Machines is an essential part of Cloud Computing and as such, it has become one of the major Cloud Administrators' role. However, when Virtual machines are created newly, they only have Operating System Disk. To be able to store application data and any other data or information on the Virtual machine, data disk needs to be added.

Data disks attached to Virtual machines are managed disk. This is because they are created and managed by Cloud Service Providers(CSP). Managed Disks have several benefits compared to unmanaged disks.

First, the management of the disk is simple because you don't have to bother yourself about managing storage accounts, blob containers, or dealing with manual scaling and configuration. The CSP takes care of all these.

Second, reliability is enhanced. Managed disks provide built-in redundancy and high availability. Data are replicated  within the same region, ensuring that your data remains intact even if an individual disk or underlying hardware fails. These type of disk provide a reliable and convenient solution for data recovery, ensuring that your data remains protected and recoverable in case of any unforeseen occurrence.

Thirdly, managed disks offer improved performance and low latency by leveraging on the cloud service provider's infrastructure and storage optimization techniques. There is also different disk types with varying performance characteristics, such as Standard HDD, Standard SSD, and Premium SSD, based on your workload requirements, that you can choose from.

Finally, managed disk makes scalability and platform integration easy.

Now we will set out to create a Windows Virtual machine, connect to it, install a web server on it, add a data disk and initialise it for use.
Come on and let's do these together.

**Step 1**
I will start by logging in to Azure Portal and select Virtual Machine

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


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

**Step 2**
Click on 'Create'

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

Complete the Project details and Instance details
I will choose to complete them as follows:

Subscription : Azure Pass Sponsorship
Resource Group: UniRg
Virtual Machine Name: Abiksvm
Region: East US
Availability option: Availability zone
Image: Windows Server 2019 Datacenter - x64 Gen 2
Leave other parameters at default


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


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



**Step 3**
Complete the details for Administrator account
I will choose my Username as **Azureuser** and password is **Password123***(Note that you can choose any username and password you desire)

Under Select Inbound ports, click on 'HTTP (80)' and 'RDP (3389)'


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

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

Go to Monitoring and disable Diagnostics

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

Click on Review and Create

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

Then Click on Create and wait for the deployment to complete

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

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

Click on 'Go to Resource'

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

**Step 4**
Connect to the Virtual machine 
Click on Connect

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

Click on 'Download RDP File'


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

Open the RDP File downloaded, it will bring up a dialog box for Remote Desktop Connection

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

Click Connect

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

Enter the Username and Password created under the Administrator Account in Step (3) above to log in to the Virtual machine **Abiksvm** and click OK


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


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

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

We have connected to the Virtual Machine

**Step 5**
Install a Web Server role on the Virtual Machine
Type PowerShell into the Search window of the Virtual Machine

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

Right click on the Windows PowerShell and then click on Run as Administrator

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

When the Terminal is ready, type in this command:
**Install-WindowsFeature Web-Server**


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

Then press Enter on your keyboard and wait for the Installation to complete

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


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

The Web Server role has been installed. Lets check this out.

Go back to the Overview page of the Virtual machine Abiksvm on the Azure portal and copy the IP Address of the VM


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

Paste the IP Address in your browser and press Enter on your keyboard

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


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

That's it! A Windows Server has been installed.

**Step 6**
Add Data Disk to Virtual Machine Abiksvm
On the VM, Click on 'Disks' and then, click on 'Create and attach a new disk'



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

Give the disk a name. I will name it **datadisk** and change the size to 10GB

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


Click on 'Save'

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

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

The Data disk has been created

**Step 7**
Initialise the Data disk
Go back to the VM we connected to earlier and type 'disk management' in the search window

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

Click on 'Create and format hard disk partitions'

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

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


Click OK


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

Scroll down to Disk 2 and Right click on 'New Simple Volume'

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


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

Click Next

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

Click Next

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

Click Next

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

Give the Volume label a name and click next. I will give it the same name I used on Azure Portal, **datadisk**

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


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

Click on Finish

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

The Data disk has been successfully initialised and ready for use.

Trust you find this useful. Please let's have your comments.