While creating VM password should not ask

sns 9,226 Reputation points

While creating VM password should not ask in the cloud shell, PFA.
Is there any way to achieve it? Please suggest.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,283 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. JimmySalian-2011 41,926 Reputation points


    Yes it is possible to provide a variable at the start of the script and pass it in the command. Please check this article for detailed steps.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    please don't forget to upvote and Accept as answer if the reply is helpful

    0 comments No comments

  2. Andriy Bilous 10,996 Reputation points MVP

    Hello @sns

    You are using command az vm create to create VM from image Win2012R2Datacenter.
    Windows Server 2012 R2 does not support SSH key authentication, you have to use username and password instead.

    Only Linux based OS images support SSH key authentication.

    If you think your question has been answered, click "Mark as Accept Answer" if just helped click "Vote as helpful". This can be beneficial to other community members reading this forum thread.

    0 comments No comments

  3. Bjoern Peters 8,856 Reputation points

    Yes, as already mentioned, it is possible to provide a password via a variable. But the question is, how can you fill that variable before?

    What is YOUR process for setting a variable before creating the VM?
    You are using cloud shell, it is always a "fresh" process, and maybe you need to set that env:variable always manually...

    The best practice I would recommend if you don't want the user to set a password manually... put the password in an Azure key vault

    0 comments No comments