How to create Windows 10 VM using Azure CLI

Saurabh Suman 20 Reputation points
2024-03-26T04:54:45.7+00:00

I have been using following query but do not get VM created

az vm create --resource-group <RG Name> --name name --image 'Windows' --admin-username "username" --vnet-name vnet--subnet subnet --nsg NSG --nic-delete-option Delete --public-ip-address ""  --security-type Standard

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,621 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,132 questions
{count} votes

Accepted answer
  1. TP 75,821 Reputation points
    2024-03-26T05:22:04.9933333+00:00

    Hi Saurabh,

    I tested below command for creating Windows 10 VM using Azure CLI and it worked (MyResourceGroup already existed):

    az vm create --resource-group MyResourceGroup --name my-vm --image "MicrosoftWindowsDesktop:Windows-10:win10-22h2-ent-g2:latest" --admin-username "username" --vnet-name vnet --subnet subnet --nsg NSG --nic-delete-option Delete --public-ip-address "" --security-type Standard
    
    

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Anveshreddy Nimmala 2,305 Reputation points Microsoft Vendor
    2024-03-26T05:34:03.8533333+00:00

    Hello Saurabh Suman,

    Welcome to the microsoft Q&A, Thankyou for posting your query here.

    please find the below documentations for creating VM using CLI.

    az-vm-create

    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-cli

    https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli

    Hope this helps you,

    If an answer has been helpful, please consider accepting the answer to help increase visibility of this question for other members of the Microsoft Q&A community. If not, please let us know what is still needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    7a6609f9-1fef-4f0e-a53e-08bcd8d2c239

    0 comments No comments

  2. Yanhong Liu 1,780 Reputation points Microsoft Vendor
    2024-03-26T09:45:46.46+00:00

    Hello Saurabh Suman,

    There are some places to pay attention to in the Azure CLI command of Windows 10 VM. First of all, there are some syntax errors in your command. For example, VNET-Subnet should be VNet-Name <Virtual Network Name>-SUBNET <subnet name>. In addition, -Image 'Windows' requires a specific Windows 10 image name. Please refer to the following commands:

    az vm create \

      --resource-group myResourceGroup \

      --name myVM \

      --image MicrosoftWindowsDesktop:Windows-10-Enterprise:version:20h2-pro:2021.04.12 \

      --admin-username myAdminUser \

      --admin-password mySecurePassword \

      --vnet-name myVNet \

      --subnet mySubnet \

      --nsg myNetworkSecurityGroup \

      --public-ip-address "" \

      --security-type Standard

    Please note that the above URN is a fictional example, not the real Windows 10 image URN. The actual URN shall be obtained through the AZ VM Image List command.

    You can use the following command:

    az vm image list --offer Windows-10-enterprise --all --output table.

    Best Regards,

    Yanhong Liu

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments