How to Create a Classic Linux VM with the Azure classic CLI

Important

Classic VMs will be retired on March 1, 2023.

If you use IaaS resources from ASM, please complete your migration by March 1, 2023. We encourage you to make the switch sooner to take advantage of the many feature enhancements in Azure Resource Manager.

For more information, see Migrate your IaaS resources to Azure Resource Manager by March 1, 2023.

Note

Azure has two different deployment models for creating and working with resources: Resource Manager and Classic. This article covers using the Classic deployment model. Microsoft recommends that most new deployments use the Resource Manager model. For the Resource Manager version, see here.

This topic describes how to create a Linux virtual machine (VM) with the Azure classic CLI using the Classic deployment model. We use a Linux image from the available IMAGES on Azure. The Azure classic CLI commands give the following configuration choices, among others:

  • Connecting the VM to a virtual network
  • Adding the VM to an existing cloud service
  • Adding the VM to an existing storage account
  • Adding the VM to an availability set or location

Important

If you want your VM to use a virtual network so you can connect to it directly by hostname or set up cross-premises connections, make sure you specify the virtual network when you create the VM. A VM can be configured to join a virtual network only when you create the VM. For details on virtual networks, see Azure Virtual Network Overview.

How to create a Linux VM using the Classic deployment model

  1. Sign in to your Azure subscription using the steps listed in Connect to Azure from the Azure classic CLI.

  2. Make sure you are in the Classic deployment mode as follows:

    azure config mode asm
    
  3. Find out the Linux image that you want to load from the available images as follows:

     azure vm image list | grep "Linux"
    

    In a Windows command-prompt window, use find instead of grep.

  4. Use azure vm create to create a VM with the Linux image from the previous list. This step creates a cloud service and storage account. You could also connect this VM to an existing cloud service with a -c option. Create an SSH endpoint to log in to the Linux virtual machine with the -e option. The following example creates a VM named myVM using the Ubuntu-14_04_4-LTS image in the West US location, and adds a user name ops:

    azure vm create myVM \
        b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_4-LTS-amd64-server-20160516-en-us-30GB \
        -g ops -p P@ssw0rd! -z "Small" -e -l "West US"
    

    The output is similar to the following example:

    info:    Executing command vm create
    + Looking up image b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_4-LTS-amd64-server-20160516-en-us-30GB
    + Looking up cloud service
    info:    cloud service myVM not found.
    + Creating cloud service
    + Retrieving storage accounts
    + Creating VM
    info:    vm create command OK
    

    Note

    For a Linux virtual machine, you must provide the -e option in vm create. It is not possible to enable SSH after the virtual machine has been created. For more details on SSH, read How to Use SSH with Linux on Azure.

  5. You can verify the attributes of the VM by using the azure vm show command. The following example lists information for the VM named myVM:

    azure vm show myVM
    
  6. Start your VM with the azure vm start command as follows:

    azure vm start myVM
    

Next steps

For details on all these Azure classic CLI virtual machine commands, read the Using the Azure classic CLI with the Classic deployment API.