DEV Community

Cover image for How to Deploy and Configure a Windows Server 2022 Virtual Machine in Microsoft Azure.
Taiwo Olabode
Taiwo Olabode

Posted on

How to Deploy and Configure a Windows Server 2022 Virtual Machine in Microsoft Azure.

Meaning of Windows Server Virtual Machine and How to Deploy and Configure it in Microsoft Azure

A Windows Server Virtual Machine in Microsoft Azure is like having your own computer running the Windows Server operating system, but it's not a physical machine you keep at home or in an office—instead, it's created and run in the cloud on Microsoft's servers, meaning you don't have to buy hardware, set it up, or worry about things like power or cooling as Azure handles all that for you, and you can use it just like a regular computer to run programs, store files, host websites, or test software since it's flexible, allowing you to turn it on or off when needed and only pay for what you use, with full control to install software, change settings, and manage it yourself. Key features include choosing size and power like CPU, RAM, and storage, adding extras like virtual networks and IP addresses, scaling with Virtual Machine Scale Sets, using managed disks like fast SSD or standard HDD, ensuring availability with zones for 99.99% uptime, and saving money with Azure Hybrid Benefit if you have existing licenses, while benefits cover no hardware hassle, pay-as-you-go pricing, flexibility to create in minutes, global data centers for speed, and backup tools; use cases involve testing software, running apps like websites or databases, extending office networks, and more, with supported version Windows Server 2022, pricing based on usage per hour or second plus extras, security via trusted launch, firewalls like Network Security Groups, best practices like strong passwords and updates, and management through the Azure portal or tools like PowerShell. To deploy and configure a Windows Server 2022 Virtual Machine in Azure using the portal, sign in at portal.azure.com, search for virtual machines, click create, fill basics like subscription, name, region, availability, image Windows Server 2022, size, admin username and password, and inbound ports like RDP; then set disks like OS size and type, add data disks if needed; configure networking with virtual network, subnet, public IP, and security group; review and create, connect via RDP using the downloaded file and credentials; after, resize via settings, add or remove disks and initialize them inside the VM using diskmgmt.msc, update OS through Windows Update, manage security by editing NSG rules or changing passwords, install software like a web server via PowerShell, and handle start/stop/delete or add tags and monitoring.

In this article, we will be focusing on the following:

This set of lab exercises assumes that you have global administrator permissions to an Azure subscription

  • In the Azure Portal Search Bar, enter Resource Groups and select Resource groups from the list of results.

  • On the Resource Groups page, select Create.

  • On the Create a Resource Group page, select your subscription and enter the name rg-alpha. Set the region to East US, choose Review + Create, and then choose Create.

[!NOTE] This set of exercises assumes that you choose to deploy in the East US Region, but you can change this to another region if you choose. Just remember that each time you see East US mentioned in these instructions you will need to substitute the region you have chosen.

Create App Log Examiners security group

In this exercise, you create an Entra ID security group.

  • In the Azure Portal Search Bar, enter Azure Active Directory (or Entra ID) from the list of results.

  • On the Default Directory page, select Groups.

  • On the Groups page, choose New Group.

  • On the New Group page, provide the values in the following table and choose Create.

  • On the New Group page, provide the values in the following table and choose Create.

Property Value

Group type Security

Group name App Log Examiners

Group description App Log Examiners

Deploy and configure WS-VM1

In this exercise, you deploy and configure a Windows Server virtual machine.

  • In the Azure Portal Search Bar, enter Virtual Machines and select Virtual Machines from the list of results.

  • On the Virtual Machines page, choose Create and select Azure Virtual Machine.

  • On the Basics page of the Create A Virtual Machine wizard, select the following settings and then choose Review + Create.

Property Value

Subscription Your subscription

Resource Group rg-alpha

Virtual machine name WS-VM1

Region East US

Availability options No infrastructure redundancy required

Security type Standard

Image Windows Server 2022 Datacenter: Azure Edition – x64 Gen2
VM architecture x64

Size Standard_D4s_v3 – 4 vcpus, 16 GiB memory

Administrator account prime

Password [Select a unique

secure password] P@ssw0rdP@ssw0rd

Inbound ports RDP 3389

  • Wait for the deployment to complete. Once deployment completes choose Go to resource.

  • On the WS-VM1 properties page, choose Networking.

  • On the Networking page, select the RDP rule.

  • On the RDP rule space, change the Source to My IP address and choose Save.

This restricts incoming RDP connections to the IP address you’re currently using.

  • On the Networking page, choose Add inbound port rule.

  • On the Add inbound security rule page, configure the following settings and choose Add.

Property Value
Source Any
Source port ranges *
Destination Any
Service HTTP
Action Allow
Priority 310
Name AllowAnyHTTPInbound

  • On the WS-VM1 page, choose Connect.

  • Under Native RDP, choose Select.

  • On the Native RDP page, choose Download RDP file and then open the file. Opening the RDP file opens the Remote Desktop Connection dialog box.

  • On the Windows Security dialog box, choose More Choices and then choose Use a different account.

  • Enter the username as .\prime and the password as the secure password you chose in Step 3, and choose OK.

  • When signed into the Windows Server virtual machine, right-click on the Start hint and then choose Windows PowerShell (Admin).

  • At the elevated command prompt, type the following command and press Enter. Install-WindowsFeature Web-Server -IncludeAllSubFeature -IncludeManagementTools

  • When the installation completes run the following command to change to the web server root directory. cd c:\inetpub\wwwroot\

  • Run the following command. Wget https://raw.githubusercontent.com/Azure-Samples/html-docs-hello-world/master/index.html -OutFile index.html

-To resize the Disk,

-To Resize the ram

  • To stop or Deallocate the Virtual Machine

-To start the virtual Machine

-To Dissociate the virtual Machine

  • To associate the virtual machine

  • To test the IP Address of the Virtual Machine after installation of windows server using windows powershell

Top comments (0)