Azure virtual machine (VM) is the IaaS option provided by Azure. You can use PowerShell, Az CLI, Rest API to create a virtual machine. In this article I explain how you can create Azure VM using Azure portal. The Azure portal is a browser-based user interface to create Azure resources. This quick start shows you how to use the Azure portal to deploy a Linux virtual machine (VM) running Ubuntu 18.04 LTS.
Table of contents:
Video Tutorial:
If you are someone who likes to watch the demo and follow along, instead of reading the instructions. Please watch below video. Or you can move to next section where I explain the steps along with the screenshots.
Create virtual machine:
- Enter virtual machines in the search.
- Under Services, select Virtual machines.
- In the Virtual machines page, select Create and then Virtual machine. The Create a virtual machine page opens.
- In the Basics tab, under Project details, make sure the correct subscription is selected and then choose to Create new resource group. Enter myResourceGroup for the name.*.
- Under Instance details, enter myVM for the Virtual machine name, and choose Ubuntu 18.04 LTS – Gen2 for your Image. Leave the other defaults. The default size and pricing is only shown as an example. Size availability and pricing are dependent on your region and subscription.
NoteSome users will now see the option to create VMs in multiple zones. To learn more about this new capability, see Create virtual machines in an availability zone.
- Under Administrator account, select SSH public key.
- In Username enter azureuser.
- For SSH public key source, leave the default of Generate new key pair, and then enter myKey for the Key pair name.
- Under Inbound port rules > Public inbound ports, choose Allow selected ports and then select SSH (22) and HTTP (80) from the drop-down.
- Leave the remaining defaults and then select the Review + create button at the bottom of the page.
- On the Create a virtual machine page, you can see the details about the VM you are about to create. When you are ready, select Create.
- When the Generate new key pair window opens, select Download private key and create resource. Your key file will be download as myKey.pem. Make sure you know where the
.pem
file was downloaded; you will need the path to it in the next step. - When the deployment is finished, select Go to resource.
- On the page for your new VM, select the public IP address and copy it to your clipboard.
Connect to virtual machine
Create an SSH connection with the VM.
- If you are on a Mac or Linux machine, open a Bash prompt and set read-only permission on the .pem file using
chmod 400 ~/Downloads/myKey.pem
. If you are on a Windows machine, open a PowerShell prompt. - At your prompt, open an SSH connection to your virtual machine. Replace the IP address with the one from your VM, and replace the path to the
.pem
with the path to where the key file was downloaded.
ssh -i ~/Downloads/myKey.pem azureuser@10.111.12.123
Tip: The SSH key you created can be used the next time your create a VM in Azure. Just select the Use a key stored in Azure for SSH public key source the next time you create a VM. You already have the private key on your computer, so you won't need to download anything.
Hi Susheel,Thanks for sharing azure vm creation ,Can you please publish artivle ,how we can manage azure VM using devops like terraformand update ,manage ,change VM.
LikeLike
Hello, Sure. This needs some time to setup a lab. I’ll try to cover it by weekend.
LikeLike
You can check out this link for the steps to create Azure VM using terraform. https://the-tech-guy.in/2023/03/10/azure-vm-creation-using-terraform/
LikeLike