- Lab
- A Cloud Guru
Creating a Linux VM using Azure CLI
In this hands-on lab, we play the part of a Cloud Engineer who is tasked with using the Azure CLI to provision a Linux-based virtual machine running Nginx. This VM is intended for our web development team's newest project. In this hands-on lab, we cover Azure CLI syntax, Azure CLI help/parameters, and Network Security Groups.
Path Info
Table of Contents
-
Challenge
Create a Virtual Machine
Create a Virtual Machine Using Azure CLI and the Following Settings:
- Resource Group: (Existing resource group)
- Name: LabVM
- Image: UbuntuLTS
- Admin Username: azureuser
- Authentication Method: Generate SSH Keys
Note: The resource group has already been created for you.
- Login to the Azure Portal using the credentials provided in this hands-on lab.
- Navigate to the Cloud Shell, using the
>_
icon in the toolbar on the top-right side of the screen. - Ensure you are using PowerShell for Azure Cloud Shell.
- Click
Show advanced settings
. - Use the existing Resource Group.
- Choose the
Cloud Shell Region
that matches the location of your lab provided Resource Group. - Under the
Storage account
section selectUse existing
. - Under the
File share
section selectCreate new
and type incloudshell
. - Select
Attach storage
. - Once Cloud Shell has opened, identify the existing Resource Group using
az group list
. - Copy the value of the
name:
field. This is the Resource Group name. - Set the Resource Group variable by typing
$rg = "<insert-resource-group-name>"
and pressEnter
. - Set the virtual machine's name by creating its variable with
$vm = "kaldiVM"
. - Deploy a virtual machine (VM) by typing:
az vm create -g $rg -n $vm --image "UbuntuLTS" --admin-username "azureuser" --generate-ssh-keys
- After the VM is created copy the
publicIPAddress
for later use.
-
Challenge
Open Port 80 On the VM for Web Traffic
Open Port 80 on VM using Azure CLI
- Open port 80 on the VM we created:
az vm open-port -g $rg -n $vm --port 80
- Install Nginx by first logging into the server. Don't forget to accept the fingerprint:
ssh azureuser@<PubliIP.OF.VM>
- Update the Ubuntu VM:
sudo apt update -y
- Install Ngnix:
sudo apt-get install nginx -y
- Navigate to the web browser and paste in the VM's IP address. If successful, the default "Welcome to Nginix!" page appears.
- Open port 80 on the VM we created:
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.