This post briefly explains the way to create a two NIC Linux VM in Microsoft Azure.

The setup can not be created through the Azure web UI. Also, after creating the two NIC VM,
you are unable to see the second interface’s settings through the Azure web UI.

Create a virtual network e.g. my-net-0 and add a new address space (10.0.0.0/20).
Then add a new subnet e.g. my-net-0-0 (10.0.0.0/24).

Click add address space and Azure allocates a new address space for you (10.0.16.0/20).
Add a subnet and Azure will give you the subnet 10.0.16.0/24. Rename the subnet to my-net-0-1.


.

Install nodejs (https://nodejs.org/download/) and after you have installed it, install the azure-cli package $ npm install --global azure-cli.

The documentation for azure-cli can be found at https://azure.microsoft.com/en-us/documentation/articles/xplat-cli/ and https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-command-line-tools/.

Setup azure environment under nodejs/azure-cli:

$ azure config mode asm

$ azure account download
(This will download a file with your authorization tokens onto your hard disk.)

$ azure account import <FILE_FROM_PREVIOUS_COMMAND>

To create a two NIC VM

$ azure vm create --location "North Europe" \
--vm-size Large --virtual-network-name my-net-0 \
--subnet-names my-net-0-0 --nic-config "NetworkInterface1:my-net-0-1:::" \
--ssh 22 cloud_service_name disk_image_name username password

Some explanations:

–vm-size Large is needed to have two NIC’s in a VM
–subnet-names my-net-0-0 is the subnet for eth0
–nic-config “NetworkInterface1:my-net-0-1:::” creates eth1
–ssh 22 creates an endpoint to access your VM’s sshd
cloud_service_name: Azure creates a cloud service with the same name as your VM
username and password: When the new VM is provisioned, this username will be added to your VM.

Use $ azure vm show cloud_service_name to show details about your new VM.

Advertisements