How to create a Linux virtual machine with Azure Resource Manager templates

This article shows you how to quickly deploy a Linux virtual machine (VM) with Azure Resource Manager templates and the Azure CLI.

Templates overview

Azure Resource Manager templates are JSON files that define the infrastructure and configuration of your Azure solution. By using a template, you can repeatedly deploy your solution throughout its lifecycle and have confidence your resources are deployed in a consistent state. To learn more about the format of the template and how you construct it, see Create your first Azure Resource Manager template. To view the JSON syntax for resources types, see Define resources in Azure Resource Manager templates.

Create a resource group

An Azure resource group is a logical container into which Azure resources are deployed and managed. A resource group must be created before a virtual machine. The following example creates a resource group named myResourceGroupVM in the eastus region:

az group create --name myResourceGroup --location eastus

Create a virtual machine

The following example creates a VM from this Azure Resource Manager template with az group deployment create. Only SSH authentication is allowed. When prompted, provide the value of your own SSH public key, such as the contents of ~/.ssh/ If you need to create an SSH key pair, see How to create and use an SSH key pair for Linux VMs in Azure.

az group deployment create \
    --resource-group myResourceGroup \

In the previous example, you specified a template stored in GitHub. You can also download or create a template and specify the local path with the --template-file parameter.

Connect to virtual machine

To SSH to your VM, obtain the public IP address with az vm show:

az vm show \
    --resource-group myResourceGroup \
    --name sshvm \
    --show-details \
    --query publicIps \
    --output tsv

You can then SSH to your VM as normal. Provide you own public IP address from the preceding command:

ssh azureuser@<ipAddress>

Next steps

In this example, you created a basic Linux VM. For more Resource Manager templates that include application frameworks or create more complex environments, browse the Azure quickstart templates gallery.