While creating VM password should not ask

sns 8,176 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.
4,877 questions
No comments
{count} votes

3 answers

Sort by: Most helpful
  1. JimmySalian-2011 29,541 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

  2. Andriy Bilous 8,211 Reputation points

    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.

  3. Bjoern Peters 7,956 Reputation points MVP

    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