Create a custom virtual machine running Linux

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 information about creating a Linux VM using the Resource Manager model, see Create a Linux VM on Azure using the Portal.

Starting November 15, 2017, virtual machines will be available only in the Azure portal.

A custom virtual machine simply means a virtual machine that you create using a Featured app from the Marketplace because it does much of the work for you. Yet, you can still make configuration choices that include the following items:

  • Connecting the virtual machine to a virtual network.
  • Installing the Azure Virtual Machine Agent and Azure Virtual Machine Extensions, such as for antimalware.
  • Adding the virtual machine to existing cloud services.
  • Adding the virtual machine to an existing Storage account.
  • Adding the virtual machine to an availability set.

Important

If you want your virtual machine to use a virtual network, make sure that you specify the virtual network when you create the virtual machine.

  • Two benefits of using a virtual network are connecting directly to the virtual machine and to set up cross-premises connections.
  • A virtual machine can be configured to join a virtual network only when you create the virtual machine. For details on virtual networks, see Azure Virtual Network overview.

To create the virtual machine

  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.