Create a virtual network using the Azure CLI
A virtual network enables Azure resources, like virtual machines (VMs), to communicate privately with each other, and with the internet. In this quickstart, you learn how to create a virtual network. After creating a virtual network, you deploy two VMs into the virtual network. You then connect to the VMs from the internet, and communicate privately over the new virtual network.
Create a resource group and a virtual network
Before you can create a virtual network, you have to create a resource group to host the virtual network. Create a resource group with az group create. This example creates a resource group named myResourceGroup in the eastus location:
Create a virtual network with az network vnet create. This example creates a default virtual network named myVirtualNetwork with one subnet named default:
Create virtual machines
Create two VMs in the virtual network.
Create the first VM
Create a VM with az vm create. If SSH keys don’t already exist in a default key location, the command creates them. To use a specific set of keys, use the –ssh-key-value option. The –no-wait option creates the VM in the background, so that you can continue to the next step. This example creates a VM named myVm1:
Create the second VM
Since you used the –no-wait option in the previous step, you can go ahead and create the second VM named myVm2.
NOTE: The publicIpAddress. You will use this address to connect to the VM from the internet in the next step.
Connect to a VM from the internet
In this command, replace
Create a public IP address for the MySQL VM.
Create a NIC for the MySQL VM.
Create a MySQL VM in the back-end subnet.