Week1
1. Provisioning a VM via Azure Portal
Overview
This exercise introduces the Azure Portal, guiding you through the creation of a Virtual Machine (VM). You will configure an Ubuntu Linux VM with a username/password for access and verify that the VM is running successfully by logging into the VM from Azure Cloud Shell.
Step 1: Log in to Azure Portal
- Open a web browser and navigate to the Azure Portal.
- Sign in using your Azure account credentials.
Step 2: Create a Resource Group
- In the Azure Portal, search for “Resource groups” in the search bar.
- Click “Create” and fill in the following:
- Subscription: Choose your subscription.
- Resource Group Name:
LabResourceGroup - Region: Choose a region (e.g.
North Europe).
- Click Review + Create and then Create.
💡 Information
»
1. Provision a Virtual Machine on Azure and Install an Nginx Web Server
Video
Introduction
This tutorial is designed for individuals with a basic understanding of cloud concepts and who are interested in learning how to set up a virtual machine (VM) on Azure and deploy an Nginx web server. We will go step-by-step through the process, emphasizing best practices and troubleshooting.
Method
- We will use the Azure web console to manually provision a VM running the Linux distribution Ubuntu as Operating System (OS)
- We will deploy an Nginx web server by using the Ubuntu package manager running cloud-init.
- We will use a locally installed terminal to access the server (GitBash on Windows)
Prerequisites
- An Azure account. If you don’t have one, sign up here.
- Basic knowledge of cloud computing and familiarity with command-line interfaces (CLI).
- For Windows users: GitBash or similar terminal (Mac and Linux users can use the pre-installed terminal)
Provision a Virtual Machine
Log into Azure Portal
»
2. Provisioning a VM with SSH Keys and Exploring Linux
Overview
This exercise introduces secure SSH authentication using Azure Portal’s Generate Key Pair feature. You will also connect to the VM using SSH from your local (your laptop) Terminal. While logged in we will explore the Linux filesystem with basic command-line utilities.
Step 1: Log in to Azure Portal
- Open a web browser and navigate to the Azure Portal.
- Sign in using your Azure account credentials.
Step 2: Create a Virtual Machine with SSH Key Pair
- Navigate to Virtual Machines and click Create > Azure Virtual machine.
- Configure the VM:
- Subscription: Select your subscription.
- Create a new Resource Group:
LabSSHResourceGroup. (You can create a new resource group here if you don´t have one already) - Virtual Machine Name:
LabSSHVM. - Region: Same as the resource group.
- Zone options: Select Azure-selected zone
- Image: Select
Ubuntu Server 24.04 LTS. - Size: Choose
Standard_B1s. - Authentication Type: Select SSH Public Key.
- Username:
azureuser.
- Under SSH Public Key Source, select Generate new key pair.
- Configure inbound ports:
- Check Allow selected ports and select HTTP (80) and SSH (22).
- Note the name for your key pair (e.g.,
LabSSHKey) and click Download private key and create resource.
💡 Information
»
3. Automating Nginx Installation with Custom Data Scripts
Overview
This exercise introduces the use of custom data scripts to automate the installation of Nginx during VM provisioning. You will also edit the default Nginx index page to display custom content.
Step 1: Log in to Azure Portal
- Open a web browser and navigate to the Azure Portal.
- Sign in using your Azure account credentials.
Step 2: Create a Virtual Machine with Custom Data
Navigate to Virtual Machines in the Azure Portal and click Create > Virtual machine.
»
4. Creating a Resource Group Using AZ CLI
Overview
This exercise introduces the Azure CLI for managing Azure resources. You will use Azure CLI commands to create a resource group and verify its creation.
Step 1: Log in to Azure Cloud Shell
- Open the Azure Portal and click the Cloud Shell icon (top-right corner).
- Select Bash as your shell environment if prompted.
💡 Information
»
The Azure Cloud Shell is a Terminal in the Azure Portal that comes pre-configured with the Azure CLI. It enables you to run CLI commands without additional setup.
5. Provisioning a VM Using AZ CLI, Configuring Nginx, and Allowing HTTP Traffic
Overview
This exercise introduces creating a Virtual Machine (VM) with Azure CLI, using default SSH keys for secure authentication, installing Nginx, and configuring the network to allow HTTP traffic. You will work exclusively in the VSCode Integrated Terminal (Windows users: Make sure you use Git Bash).
Step 1: Set Up the Environment
Open VSCode and launch the Integrated Terminal:
- On Windows, use Git Bash inside VSCode.
- On Mac or Linux, use the default terminal.
Verify that Azure CLI is installed by running:
»
6. Automating VM Creation, Nginx Installation, and Port Configuration Using a Bash Script
Overview
In this exercise, you will create a Bash script that automates the provisioning of a resource group, a VM, and the opening of port 80. You will also use a custom data file to automatically install and configure Nginx on the VM during provisioning. This exercise enables a “one-click” solution for deploying a web server.
Step 1: Prepare the Custom Data File
Create a file named
»custom_data_nginx.sh(You can use VSCode)