Featured image

Mastering Azure Virtual Machines: A Comprehensive Guide to Deploying and Managing Windows VMs

Azure Virtual Machines (VMs) are at the core of many cloud computing strategies, providing scalable, flexible, and powerful computing resources on demand. Whether you are developing applications, running enterprise workloads, or testing new software, Azure VMs allow you to create Windows or Linux environments tailored to your requirements.

In this guide, we will dive deep into deploying a Windows Server VM in Azure using the Azure Portal, configuring network and security settings, connecting to the VM via Remote Desktop Protocol (RDP), installing essential software like IIS, and managing costs through automation features such as auto-shutdown. This tutorial is aimed at intermediate to advanced users who want a practical and thorough understanding of Azure VM deployment and management.


Why Use Azure Virtual Machines?

Azure VMs offer several advantages:

  • Scalability: Quickly scale resources up or down to meet demand.
  • Flexibility: Choose from various operating systems, sizes, and configurations.
  • Integration: Seamlessly integrate with Azure services like networking, storage, and monitoring.
  • Cost Efficiency: Pay only for what you use, and leverage features like auto-shutdown to reduce costs.

Prerequisites

Before starting, ensure you have:

  • An active Azure subscription.
  • Basic knowledge of cloud concepts and networking.
  • A Windows or Mac computer with an RDP client for remote access.

Step 1: Creating a Windows Virtual Machine in Azure Portal

Azure Portal provides an intuitive, browser-based interface for managing your cloud resources. Follow these steps to create a Windows Server 2022 Datacenter VM:

1. Sign in to Azure Portal

Navigate to https://portal.azure.com and sign in with your Azure credentials.

2. Start VM Creation

  • In the search bar at the top, type virtual machines.
  • Select Virtual machines from the Services list.
  • Click the Create button and then Azure virtual machine.

3. Configure Basic Settings

  • Virtual machine name: Enter a unique name, e.g., myWinServerVM.
  • Region: Select the Azure region closest to your users for better performance.
  • Image: Choose Windows Server 2022 Datacenter: Azure Edition - x64 Gen 2.
  • Size: Keep defaults or select a size based on your workload needs.

4. Administrator Account

  • Provide a secure username, such as azureuser.
  • Set a strong password (minimum 12 characters, with complexity requirements). Avoid common passwords to maintain security.

5. Inbound Port Rules

  • Choose Allow selected ports.
  • Select RDP (3389) to enable remote desktop access.
  • Select HTTP (80) to allow web traffic for IIS.

6. Review and Create

  • Click Review + create to validate your configuration.
  • After validation, click Create to deploy your VM.

Step 2: Connecting to Your Azure VM

Once the VM is deployed, you can connect to it using RDP.

Connecting from Windows

  1. Go to your VM’s Overview page in the Azure Portal.
  2. Click Connect > RDP.
  3. Download the RDP file.
  4. Open the downloaded file and click Connect.
  5. When prompted, provide credentials in the format localhost\\azureuser with your password.
  6. If you see a certificate warning, click Yes to proceed.

Connecting from macOS


Step 3: Installing IIS Web Server on Your VM

To verify your VM is operational and can serve web content, install the IIS web server:

  1. Open PowerShell on the VM (search for PowerShell in the Start menu).
  2. Run the following command:
Install-WindowsFeature -name Web-Server -IncludeManagementTools
  1. Wait for the installation to complete.

Step 4: Verifying IIS Installation

Back in the Azure Portal:

  1. Copy the public IP address of your VM from the Overview page.
  2. Paste the IP address into a web browser.

You should see the default IIS welcome page confirming that your web server is running successfully.

IIS Default Welcome Page


Step 5: Managing Your Azure VM

Cleaning Up Resources

When you are done with the VM, it’s important to delete the resources to avoid unnecessary charges:

  1. In the VM’s Overview page, click the Resource group link.
  2. Click Delete resource group at the top.
  3. Confirm by typing the resource group name and click Delete.

Enabling Auto-Shutdown

To optimize costs, configure auto-shutdown:

  1. Navigate to the VM’s Operations section.
  2. Select Auto-shutdown.
  3. Turn on auto-shutdown and set the time according to your timezone.
  4. Save the configuration.

This ensures your VM doesn’t run idle and incur charges when not in use.


Best Practices for Azure VM Deployment

  • Choose the right VM size: Analyze your workload requirements to balance cost and performance.
  • Use availability zones: Deploy VMs across zones for high availability.
  • Secure your VM: Use Network Security Groups (NSGs) to limit inbound traffic and enable Azure Defender for threat protection.
  • Automate deployments: Use ARM templates or Terraform for repeatable and consistent VM deployments.
  • Monitor performance: Utilize Azure Monitor and Log Analytics to track VM health and resource usage.

Real-World Scenario: Deploying a Web Application Environment

Imagine you are a developer tasked with deploying a test environment for a new web application:

  1. Provision a Windows Server VM using the Azure Portal.
  2. Install IIS and configure it to host the web app.
  3. Open necessary ports (80 for HTTP, 443 for HTTPS).
  4. Set Auto-shutdown to minimize costs overnight.
  5. Connect via RDP to deploy your app binaries.
  6. Monitor performance and scale up the VM size if needed.

This approach provides a controlled, cost-effective environment to test and iterate rapidly.


Conclusion

Azure Virtual Machines empower you to run diverse workloads in the cloud with flexibility and control. By following this guide, you can confidently create Windows VMs, configure networking and security, deploy applications like IIS, and manage your resources efficiently.

To deepen your knowledge, explore Azure VM tutorials focusing on advanced features such as VM scale sets, custom images, and Azure Automation.


Additional Resources


Happy cloud computing with Azure VMs!