This project demonstrates how to create and deploy a Virtual Machine (VM) on Microsoft Azure using Azure CLI.
I also automated the entire process using a Bash script to make the deployment faster and more efficient.
The script:
- Logs into Azure
- Creates a Resource Group
- Deploys a Virtual Machine
- Opens port 80 to allow web traffic
- Retrieves the public IP address of the VM
- Provides an option to automatically clean up resources to avoid extra costs
- Project Overview
- Technologies Used
- Prerequisites
- Folder Structure
- How to Use the Bash Script
- Manual Deployment Steps
- Learnings
- Resources
- image
- Azure CLI
- Ubuntu 22.04 LTS Virtual Machine
- Bash scripting
- Azure CLI installed on your machine
- An active Azure subscription
- Basic terminal/command line knowledge
- SSH key setup (Azure CLI can auto-generate this)
azure-vm-deployment/
βββ image/ # Screenshot of successful deployment
βββ README.md #Project documentation
βββ vm-deployment.sh #Bash automation script
If you want to manually deploy the VM instead of using the Bash script, follow these steps:
az login
### 2. Create a Virtual Machine using Azure CLI.
```bash
az vm create \
--resource-group <your-resource-group> \
--name <your-vm-name> \
--image Ubuntu2204 \
--admin-username azureuser \
--generate-ssh-keys
### 3. Open port 80 to allow web traffic:
```bash
az vm open-port --port 80 --resource-group <your-resource-group> --name <your-vm-name>
### 4. Retrieve the public IP address of the VM:
```bash
az vm list-ip-addresses --name <your-vm-name> --resource-group <your-resource-group>
### 5. Connect to the VM via SSH:
```bash
ssh azureuser@<your-public-ip>
In your terminal, navigate to the project folder and run:
chmod +x vm-deployment.sh
### 2. Execute the script with
```bash
./vm-deployment.sh
### 3. After the script finishes, it will display the SSH command.
Use it to connect to your VM:
```bash
azureuser@<your-public-ip>
- How to deploy and manage Azure cloud resources using CLI.
- How to automate virtual machine deployment with Bash.
- How to securely connect to virtual machines using SSH.
- The importance of cleaning up resources to prevent unnecessary cloud costs.
- Screenshot of successful deployment