az Verified current stable Not installed? Cloud Infrastructure

Az / Create Vm Ubuntu

Create Vm Ubuntu

Az command syntax to create vm ubuntu. Copyable examples, output expectations, and common mistakes.

$
Terminal
az vm create -g <rg> -n <vm_name> --image <UbuntuLTS> --admin-user <azureuser> --generate-ssh-keys

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Creating VM "vm_name" in resource group "rg"...

...\n
Resource group created: rg
VM created successfully!

Public IP address: 40.112.120.14
VM ID: f8b7fcd2-1a11-48c8-bffc-4e8f2333f7e3
Power state: running

Command Breakdown

What each part is doing

az
Base Command
The executable that performs this operation. Here it runs Az before the shell applies any redirect operators.
-g
g| resource group
The value supplied for g| resource group.
<rg>
rg
The value supplied for rg.
-n
n| name
The value supplied for n| name.
<vm_name>
vm name
The value supplied for vm name.
<UbuntuLTS>
UbuntuLTS
The value supplied for UbuntuLTS.
<azureuser>
azureuser
The user value supplied to this command.
-g
Command Option
Tool-specific option used by this command invocation.
-n
Command Option
Tool-specific option used by this command invocation.
--image
Command Option
Tool-specific option used by this command invocation.
--admin-user
Command Option
Tool-specific option used by this command invocation.
--generate-ssh-keys
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: az vm create -g rg -n vm_name --image UbuntuLTS --admin-user azureuser --generate-ssh-keys

  2. Step 2

    Verify VM creation: az vm list -g rg --output table

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.