Step-by-Step: Deploy a new Linux VM from a captured image

Hello folks,

in my last post we discussed who to capture an existing Linux machine in Azure in order to be able to deploy new instances of that machine.  In effect turning that machine into a template.

Now, we’ll use that image, Azure CLI and the and the JSON template the last process generated to create a new Linux VM in a new virtual network.


Creating environment to deploy the template.

To deploy the Linux machine we imaged in the last post we need to set up a virtual network and NIC for your new VM. Furthermore, we recommend using a new resource group for these resources in the location where your VM image is stored.

Using Azure CLI we will use the following command in order to create the Resource Group, the virtual network, the subnet with address space and the public IP address.

In these command I will use the following :

  1. RG-New-CDNeast-1 as my new resource group name.
  2. East US "eastus" is the location.
  3. VNet1 is the virtual network name
  4. FrontEnd is the subnet name
  5. publicip is the Public IP object name


azure group create RG-New-CDNeast-1 -l "eastus"
azure network vnet create RG-New-CDNeast-1 VNet1 -l "eastus"
azure network vnet subnet create RG-New-CDNeast-1 VNet1 -n FrontEnd -a
azure network public-ip create RG-New-CDNeast-1 publicip -l "eastus"
azure network nic create RG-New-CDNeast-1 NIC-1 -k frontend -m VNet1 -p publicip -l "eastus"












Now that our environment is created we will deploy a new VM using the template we created in the last post.  However, we do need the you'll need the Id of the NIC we created in the last command we ran above.  if this is still on your screen copy it.  if you closed/cleared the terminal screen already you can get it back with the following command:

azure network nic show RG-New-CDNeast-1 NIC-1

In my case the ID is:




Create a new deployment of our template.


now that the environment is setup, we can use one command to deploy a new VM using our template. (note:  I moved the template to a different machine and path from the last post)


azure group deployment create RG-New-CDNeast-1 newlinuxvm -f "C:\Users\pierrer\OneDrive - Pierre Roman\blog\template.json"

the command will prompt you for a VM name, an administrator account name, with it’s password and the NIC ID.  You copied it right??

After a bit the command will complete.



Here we are.  A new VM has been created.  And because this is a JSON template you can modify it  to fit your needs.  For example, if you wanted to change the VM size you would have to edit the template VMSize section.



I hope this helps,

Cheers! Signature

Pierre Roman