Creating Azure virtual network using Azure Portal

Creating Azure virtual network using Azure Portal

In last few posts, I have tried to cover basic concepts those would be required for hands on. If you want to have a look at them, below is the list:

In this article, let’s create the virtual network and setup a couple of virtual machines. The machines would be connected and would allow connections from each other.

You would need to have an Azure account with an active subscription.  If you do not have it yet, you can create one for free. And then sign in to the Azure portal.

Create Virtual Network

From the Azure portal menu, select Create a resource.

From the Azure Marketplace, select Networking > Virtual network.

In first screen of Create Virtual Network wizard, provide below details:

  • Subscription: select appropriate subscription,
  • Resource Group: create a new resource group with name blog-samples .
  • Name: the name for virtual network, e.g. blog-demo-vnet
  • Region: the region where the resource should be created
Azure Portal: Create virtual network wizard
Azure Portal: Create virtual network wizard

On next screen of IP Addresses,

  • IPv4 Address Space, For this demo, select the default IPv4 Address space and select the default addresses 10.1.0.0/16.
  • Subnet, keep the default subnet (10.1.0.0/24), make sure you check both the checkboxes

Then click on Review + Create button and then click on Create button. It would take couple of seconds to create the virtual network.

Azure Portal: Create virtual network IP Addresses panel
Azure Portal: Create virtual network IP Addresses panel

Create Virtual Machine

Now, let’s create first virtual machine using Azure Portal.

Search for Virtual Machine in top search box, click on first entry and then click on Add to create a new virtual machine.

On the first “Basic” screen of create VM wizard, provide appropriate subscription, the same resource group where virtual network is placed. Name the Azure virtual machine as demo-vm1. Also, set the appropriate image and size. Provide a username for admin login and its password. Then select Networking tab from the wizard.

Azure Portal: Create a virtual machine
Azure Portal: Create a virtual machine

On the networking tab, make sure that the virtual network that we created in first step is selected. In subnet, select the default subnet from the virtual network is selected. Under Public IP, keep the default input, which suggests to create a new IP for this VM. Under public inbound ports, select only port 80 and port 3389 as shown in below snapshot. Keep rest of the inputs to their defaults.

Azure Portal: Networking tab in create virtual machine wizard
Azure Portal: Networking tab in create virtual machine wizard

Then click on Review + Create which would validate all inputs. If all inputs are valid then click on Create to trigger the VM creation.

Create another virtual machine

Follow same steps as above to create second VM. This time, use demo-vm2 as the name of second virtual machine. Once this step is complete, you should have two VMs in the virtual network

Verification of Connectivity

Now, connect to demo-vm1 via remote desktop connection. Then open the PoweShell prompt and run command ping demo-vm2. This should display successful response.

Alternatively if you try to connect now to demo-vm2 via remote desktop connection and try pinging demo-vm1 from demo-vm2, it should also result in successful ping. So, we successfully added two VMs to a virtual network.

The ping command would also print their private IPs (IPs inside the virtual network, which would be 10.1.0.4 and 10.1.0.5). Why first four IPs are not used (from 10.1.0.0 to 10.1.0.3) ? Because those are reserved by Azure.

I hope you found this information useful. Let me know your thoughts.

Leave a Reply