Create an Azure Virtual Machine via CLI
In this lesson, you will use the CLI to create an Azure virtual machine (VM), install Nginx (a popular web server), and then delete the VM along with all associated resources. You will use the Azure CLI for this task and work within a resource group named FreeResourcesRG.
Task 1: Create a Linux Virtual Machine and Install Nginx
Use the following Azure CLI commands to create a Linux VM and install Nginx. The Custom Script Extension will be used to install Nginx on your VM after it is created.
Open Cloud Shell
Access the Azure Portal.
Click on the Cloud Shell icon in the top menu bar.
Create a Linux Virtual Machine
Run the following command to create a Linux VM in the FreeResourcesRG resource group:
This command will create a VM named my-vm with Ubuntu 22.04, using SSH keys for authentication. The VM creation will take a few minutes.
Install Nginx on the VM
After the VM is created, run the following command to install Nginx using the Custom Script Extension:
This command will:
- Download the Bash script from GitHub.
- Run the script to update the package list, install Nginx, and set a custom welcome message.
Task 2: Verify Nginx Installation
Get the Public IP Address
Run the following command to get the public IP address of your VM:…
No comments yet. Add the first comment to start the discussion.