Deploy Windows Server on Azure
Learn how to quickly provision a Windows Server virtual machine in Microsoft Azure, configure networking, and secure your deployment.
Prerequisites
- Azure subscription with Contributor role.
- Azure CLI installed (
azversion 2.50+). - Basic familiarity with PowerShell or Bash.
Step 1 – Log in to Azure
az login
This opens a browser window for authentication. After successful login you’ll see a list of subscriptions.
Step 2 – Choose a Resource Group
az group create --name MyResourceGroup --location eastus
If the resource group already exists, you can skip this step.
Step 3 – Create the Windows Server VM
az vm create \
--resource-group MyResourceGroup \
--name WinServerVM \
--image Win2022Datacenter \
--admin-username azureuser \
--admin-password MySecureP@ssw0rd! \
--size Standard_DS2_v2 \
--location eastus \
--public-ip-sku Standard
This command creates a VM with Windows Server 2022 Datacenter, a public IP, and a standard D2 v2 size.
Step 4 – Open RDP Port (3389)
az vm open-port --resource-group MyResourceGroup --name WinServerVM --port 3389
Ensures you can connect via Remote Desktop.
Step 5 – Connect to the VM
Use the public IP displayed after the VM creation. Open mstsc (Remote Desktop Connection) and enter the IP address.
Optional – Install IIS via PowerShell
Invoke-Command -ComputerName <PublicIP> -Credential (Get-Credential) -ScriptBlock { Install-WindowsFeature -Name Web-Server }
This runs a remote PowerShell command to install Internet Information Services (IIS) on your server.