Virtual machines (VMs) 3 – Compute

Let’s understand how we can deploy a VM on a cloud platform. To deploy a VM in a cloud environment such as Azure, you can follow these general steps (I’ll provide an example using the Azure cloud platform):

  1. Sign in to the Azure portal: Go to the Azure portal (https://portal.azure.com/) and sign in with your Azure account.
  2. Create a resource group: A resource group is a logical container for resources. It helps you manage and organize resources in your Azure subscription. Create a new resource group or use an existing one if you have already created it.
    An example in the Azure CLI is as follows:

az group create –name MyResourceGroup –location eastus

  1. Choose the VM image: Select the operating system and VM image you want to use. Azure provides a variety of images, including Windows Server, Ubuntu, CentOS, and so on.
    An example in Azure CLI is as follows:

az vm image list –output table

  1. Create the VM: Choose a name for your VM, determine the size (hardware configuration), and specify the login credentials (username and password or SSH key) for accessing the VM.
    An example in Azure CLI is as follows:

az vm create –resource-group MyResourceGroup –name MyVirtualMachine –image UbuntuLTS –size Standard_B2s –admin-username azureuser –admin-password MyPassword1234

  1. Configure network settings: Specify the network settings such as virtual network, subnet, public IP (if needed), and network security group rules (firewall settings).
    An example in Azure CLI (creating a new virtual network and subnet) is as follows:

az network vnet create –resource-group MyResourceGroup –name MyVnet –address-prefix 192.168.0.0/16 –subnet-name MySubnet –subnet-prefix 192.168.1.0/24

  1. Assign a public IP (optional): If you want your VM to have a public IP address to access it over the internet, you can allocate a public IP and associate it with your VM.
    An example in Azure CLI is as follows:

az network public-ip create –resource-group MyResourceGroup –name MyPublicIP –sku Standard
az network nic ip-config update –resource-group MyResourceGroup –nic-name MyVirtualMachineVMNic –name ipconfig1 –public-ip MyPublicIP

  1. Open ports (optional): If you need specific ports to be accessible from the internet, configure network security group (NSG) rules to allow incoming traffic.
    An example in Azure CLI (allowing SSH traffic on port 22) is as follows:

az network nsg rule create –resource-group MyResourceGroup –nsg-name MyNetworkSecurityGroup –name AllowSSH –protocol Tcp –direction Inbound –priority 1000 –source-address-prefix ‘‘ –source-port-range ‘‘ –destination-address-prefix ‘*’ –destination-port-range 22 –access Allow

  1. Connect to the VM: Once the VM is deployed, you can connect to it using remote desktop (RDP) for Windows VMs or SSH for Linux VMs. Use the public IP address or the fully qualified domain name (FQDN) to connect.
    That’s it! You now have a VM running in the Azure cloud environment. Remember to manage your resources efficiently and stop or deallocate the VM when not in use to avoid unnecessary costs.

Leave a Reply

Your email address will not be published. Required fields are marked *