Skip to content

πŸš€ This project demonstrates how to deploy a Virtual Machine on Azure using Azure CLI and automate the process with a Bash script. It covers resource group creation, VM setup, opening network ports, fetching the public IP, and connecting via SSH. A resource cleanup option is included to help manage cloud costs. Ideal for beginners.

Notifications You must be signed in to change notification settings

HARMONYOMA/azure-vm-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Azure Virtual Machine Deployment with Bash Automation

Project Overview

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

Table of Contents


Technologies Used

  • Azure CLI
  • Ubuntu 22.04 LTS Virtual Machine
  • Bash scripting

Prerequisites

  • Azure CLI installed on your machine
  • An active Azure subscription
  • Basic terminal/command line knowledge
  • SSH key setup (Azure CLI can auto-generate this)

Folder Structure

azure-vm-deployment/
β”œβ”€β”€ image/                 # Screenshot of successful deployment
β”œβ”€β”€ README.md              #Project documentation
└── vm-deployment.sh       #Bash automation script

Manual-deployment-steps

If you want to manually deploy the VM instead of using the Bash script, follow these steps:

1. Log into Azure using:

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>

How to Use the Bash Script

1. Make the Script Executable

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>

Learnings

  • 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.

Resources


Image

  • Screenshot of successful deployment

About

πŸš€ This project demonstrates how to deploy a Virtual Machine on Azure using Azure CLI and automate the process with a Bash script. It covers resource group creation, VM setup, opening network ports, fetching the public IP, and connecting via SSH. A resource cleanup option is included to help manage cloud costs. Ideal for beginners.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages