How to create an Azure Virtual Machine to run Magento 2 with Ubuntu

Table of Contents

Overview

Create a Linux virtual machine in the Azure portal

Sign in to Azure

Sign in to the Azure Portal: Go to the Azure Portal and sign in with your credentials.

Create virtual machine

Step 1: Search for Virtual Machines:

  • In the search bar, enter Virtual machines. Under Services, select Virtual machines.

Step 2: Create a New Resource Group:

  • In the Basics tab, under Project details, select the correct Subscription.
  • Choose Create new to create a new resource group.
  • Enter myResourceGroup as the name.

    AD 4nXfizeRHHFTB9NcrZdxNz

Step 3: Configure VM Basics:

  • Under Instance details, enter myVM as the name of your virtual machine.
  • For Image, select Ubuntu Server 24.04 LTS – Gen2.
  • You may leave other settings at their default values.
    Note: The default size and pricing shown are examples only. Availability and pricing may vary depending on your region and subscription. For optimal performance, consider a configuration with 4 vCPUs and 16 GiB of memory.

    AD 4nXeeScp8JhA4P 6btjQXn5EEe2LErRQ ElrcAH4bZpmGmkwP mx0uhqoRUWIv W U2EF27i3GTriqYKZMlaYBRF4C3tZHBOvtMYXzHU77IhK8R1iPFC5tPWzmXxY sf74pwQ6n3w7g?key=g3rNWJCz60zkbk2GNO1BGigI

Step 4: Set up SSH Credentials:

  • Under the 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.

    AD 4nXcO ej1IIZNplLKJl SGtK iQslxZe4rUpHTf bcg kmRK671T8uLxYFi39rJm4LXRdB7uFH27EoGoTGKniVPR m2MYAbIut91BKFQVRZ8vvKd8yHgczCjEpN 7IKy1VHd6q ntrg?key=g3rNWJCz60zkbk2GNO1BGigI

Step 5: In the Disks tab, please set it as default.

AD 4nXcS1ei4z62AoXxDARwkF1zKMTzs pbncQIj6XYCTU0l0ZDgZVu1PscFSbvXPUiASuO6TVEyfs6cl65pSYLl5DGXTExvLYT6FoojZ9tmEaSHmnuX7PsRsQTL3PJt9Lc zLgYawcCIw?key=g3rNWJCz60zkbk2GNO1BGigI

Step 6: Leave the remaining defaults and then select the Review + create button at the bottom of the page.

Step 7: 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.

Step 8: When the Generate new key pair window opens, select Download private key and create resource. Your key file will be downloaded as myKey.pem. Make sure you know where the .pem file was downloaded; you will need the path to it in the next step.

Step 9: When the deployment is finished, select Go to resource.

Step 10: On the page for your new VM, select the public IP address and copy it to your clipboard.


If you’re looking for a more in-depth, step-by-step guide on how to connect to your newly created Azure instance via SSH, be sure to check out our detailed tutorial here:
How to Connect to Azure Instance Using SSH.
This resource covers additional troubleshooting tips, best practices for key management, and advanced configuration options to ensure a smooth and secure connection to your Azure environment.

By following the steps above, you’ve successfully created a new virtual machine with Ubuntu Server 24.04 LTS, set up secure SSH access, and generated a key pair for authentication. After finalizing the configuration and deployment, you obtained the VM’s public IP address, allowing you to connect remotely. We hope this article helps you save time and effort. Please feel free to contact us if you need any additional support.

References