Deploying Web Server for Internet Information Services (IIS) on Azure Virtual Machine

In this blog post, we’ll cover:

  • An introduction to using the Azure CLI for resource management
  • How to launch and use Azure Cloud Shell
  • Steps to create an Azure Resource Group
  • How to deploy a Windows Server 2022 virtual machine (VM)
  • Installing the IIS web server remotely
  • Opening network ports to allow web traffic
  • Accessing the web server in a browser
  • Instructions for cleaning up resources to avoid unnecessary costs

Whether you are a developer, system administrator, or IT professional, managing Azure resources via the command line can be faster and more repeatable than clicking through the portal. This quickstart walks you through the process of deploying a Windows Server 2022 virtual machine (VM) using the Azure CLI, installing IIS, and accessing it from the internet.

If you don’t have an Azure subscription, you can create a free account before you begin.

Launch Azure Cloud Shell

To make things simple, we will use the Azure Cloud Shell. It’s a free, browser-based shell with all the Azure tools preinstalled. You don’t need to install anything on your local machine.

You can open the Cloud Shell by selecting Try it in the upper-right corner of any code block in this post, or go directly to shell.azure.com/bash.

Step 1: Create a Resource Group

A resource group is a logical container that holds all your Azure resources. Use the following commands to set your subscription and create a resource group. Replace the variable values as needed.

Azure CLI

Step 2: Create the Virtual Machine

Now, let’s create the VM. The command below will create a VM named myVM using the Windows Server 2022 image. You will be prompted to enter a password that meets Azure’s complexity requirements.

Azure CLI

Note: It takes a few minutes for the VM and its supporting resources to be created.

Once the process completes, you’ll see output similar to this. Make sure to copy the publicIpAddress—you’ll need it later.

json

Step 3: Install the IIS Web Server

To see your VM in action, we’ll install the IIS web server using a remote PowerShell command.

Azure CLI

Step 4: Open Port 80 for Web Traffic

By default, only RDP (port 3389) is open. To allow web traffic, we need to open port 80.

Azure CLI

Step 5: View the Web Server

Open your browser and navigate to http://<your-public-ip-address>. You should see the default IIS welcome page, confirming your server is up and running.

Clean Up Resources

To avoid incurring unnecessary charges, delete the resource group when you no longer need the VM. This will remove all associated resources.

Azure CLI

Final Thoughts

Using the Azure CLI allows you to automate and streamline the deployment of virtual machines. In just a few commands, you went from no infrastructure to a fully functional Windows Server with a web server accessible online.

Scroll to Top