While creating VM password should not ask

sns 9,226 Reputation points
2022-08-26T04:18:32.64+00:00

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

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

3 answers

Sort by: Most helpful
  1. JimmySalian-2011 41,916 Reputation points
    2022-08-26T05:40:23.58+00:00

    Hi,

    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.

    create-configure-vm-azure-cli

    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,901 Reputation points MVP
    2022-08-26T05:44:55.917+00:00

    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.
    https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-cli#create-virtual-machine

    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,781 Reputation points
    2022-08-26T11:33:43.197+00:00

    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
    https://learn.microsoft.com/en-us/azure/key-vault/keys/quick-create-cli

    0 comments No comments