This assignment is designed to introduce you to Azure Virtual Machines, covering the setup, configuration, and basic management of VMs. By the end of this assignment, you will understand how to deploy, access, and manage VMs on Microsoft Azure.
Log in to Azure Portal
Create a New Virtual Machine
Configure the VM Settings
RG-AzureVM-Assignment
.StudentVM-{your initials}
.France Central
).Zone 3
.Ubuntu Server 20.04 LTS
.Standard B1s
(to minimize cost).Create and Deploy the VM
Document Your VM Configuration
Access the VM
Connect -> Native SSH
. You need the previously downloaded key.Basic Commands
uname -a
: Check the operating system version.df -h
: Check disk space usage.free -m
: Check memory usage.ping google.com
: Verify internet connectivity.Install Apache (Linux)
sudo apt update
sudo apt install apache2 -y
Verify Web Server Installation
http://<Your-VM-Public-IP>
.Install Docker
sudo apt update
sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
Verify Docker Installation
docker --version
to confirm Docker is installed.Create a Simple FastAPI App
mkdir ~/fastapi-app
cd ~/fastapi-app
main.py
with the following FastAPI code:from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello, Azure!"}
Create a Dockerfile for the FastAPI App
fastapi-app
directory, create a file named Dockerfile
with the following content:# Use an official Python runtime as a parent image
FROM python:3.9
# Set the working directory
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install FastAPI and Uvicorn
RUN pip install fastapi uvicorn
# Make port 3000 available to the world outside this container
EXPOSE 3000
# Run app with Uvicorn on container startup
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3000"]
Build and Run the Docker Container
docker build -t fastapi-app .
docker run -d -p 3000:3000 fastapi-app
Test the FastAPI Application
http://<Your-VM-Public-IP>:3000/
to test the FastAPI app.*
Destination port 3000
, Service Custom
, TCP).http://<Your-VM-Public-IP>:3000/
.RG-AzureVM-Assignment
.Deploy the website your created in the previous assignement on port 5222.