An Azure service that is used to provision Windows and Linux virtual machines.
Hello Itamar aTabacof,
Greetings! Thanks for raising this question in the Q&A forum.
A logon of more than 2 minutes on a clean Windows Server 2022 image is almost always a resource or disk bottleneck rather than a Windows fault. The usual causes are a small or burstable VM size (for example B-series with exhausted CPU credits, or only 1 to 2 vCPUs and 2 to 4 GB RAM), a Standard HDD or Standard SSD OS disk with low IOPS, background activity right after provisioning (Windows Update, Microsoft Defender scans, Server Manager and the first-logon app setup), or a delay in profile and network services at logon. The "Please wait for the User Profile Service" message points to the profile load stage, which is heavily disk dependent.
- Check the VM size and the OS disk type. In the Azure portal open the VM and review
Overview > SizeandDisks > OS disk. Servers with 1 to 2 vCPUs and Standard HDD disks are commonly this slow. You can check from the CLI:
az vm show -g <rg-name> -n <vm-name> --query "{size:hardwareProfile.vmSize, osDisk:storageProfile.osDisk.managedDisk.storageAccountType}"
Look at the metrics during a slow logon. Go to Monitoring > Metrics and chart Percentage CPU, CPU Credits Remaining (B-series), OS Disk IOPS Consumed Percentage, and OS Disk Bandwidth Consumed Percentage. If the disk percentages hit 100 or CPU credits are near zero during logon, that is your bottleneck.
Move to a faster disk and a larger size if the metrics confirm it. Premium SSD (or Premium SSD v2 or Ultra for heavy use) and a non-burstable size such as D2s_v5 usually fix the problem. The VM must be deallocated to change the disk type:
az vm deallocate -g <rg-name> -n <vm-name>
az disk update -g <rg-name> -n <os-disk-name> --sku Premium_LRS
az vm resize -g <rg-name> -n <vm-name> --size Standard_D2s_v5
az vm start -g <rg-name> -n <vm-name>
- Stop unnecessary logon work. Server Manager starts at every logon and consumes resources. Disable it from an elevated PowerShell:
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ServerManager" -Name "DoNotOpenServerManagerAtLogon" -Value 1
Also check that Windows Update is not installing patches in the background (Get-WindowsUpdateLog or Settings > Windows Update), because a newly created VM often installs updates for the first hour or two.
Find the slow phase in the event logs. In Event Viewer review Applications and Services Logs > Microsoft > Windows > User Profile Service > Operational, Winlogon > Operational, and GroupPolicy > Operational. The timestamps show which stage takes the 2 minutes. Event ID 1530 or 1511 in the Application log can also point to a profile load problem.
Check Task Manager while logging in. Connect, open Task Manager as soon as possible, and sort by CPU and Disk. Note any process that stays busy (for example MsMpEng.exe for Defender, TiWorker.exe for updates, or wuauserv). If it is Defender, avoid disabling it fully and instead let the first scan finish or add scoped exclusions for your own workloads.
Capture a trace if it is still slow. If the cause is still unclear, record a logon trace with Windows Performance Recorder and review it in Windows Performance Analyzer, or open an Azure Support request with the VM resource ID, size, disk type, region, and the event log timestamps.
If this answer helps you kindly accept the answer which will help others who have similar questions.
Best Regards,
Jerald Felix.