Azure Zero to Hero: Day 4 — Deploying Jenkins on an Azure VM & Understanding VM Types
1. Introduction & Virtualization Recap
Before diving into cloud provisioning, it is essential to understand the underlying infrastructure that powers cloud platforms like Microsoft Azure.
Real-Life Analogy: The Corporate Server Dilemma
Imagine an organization or cloud provider purchasing a massive physical server equipped with extreme hardware specifications—such as 1,000 CPU cores and 100 TB of RAM. If a system administrator directly assigns this entire physical machine to a single developer, QA engineer, or DevOps practitioner, 99% of those powerful compute resources will go completely wasted.
To solve this inefficiency, modern data centers use Virtualization:
- Physical Servers: Heavy-duty bare-metal hardware procured from vendors like IBM or Dell and housed inside global data center regions (e.g., East US, Zone 1).
- The Hypervisor: A specialized virtualization software installed directly onto the physical server hardware.
- Logical Splitting: The hypervisor acts as a slicing knife, carving up the monolithic physical server into multiple isolated virtual machines (VMs) of varying sizes (e.g., 1 CPU, 2 GB RAM).
When an end-user requests a VM via the Azure Portal, the Azure Resource Manager (ARM) processes the request, locates an available compute slice within the target data center zone, and instructs the hypervisor to provision the exact configuration—either statically (pre-allocated pools) or dynamically (on-demand creation).
2. Navigating Azure Virtual Machine Creation Parameters
When provisioning a Virtual Machine in the Azure Portal, several core configuration parameters directly dictate system performance, accessibility, and financial billing.
Note on Free Tier Billing: For the first 30 days on a free trial account, Microsoft Azure grants free credits (e.g.,
$200in the US). Azure will not automatically charge your credit/debit card after the trial expires unless you explicitly provide formal consent to upgrade to the Pay-As-You-Go subscription model. If no consent is given, the account is simply suspended.
Essential VM Configuration Breakdown
- Subscription: Defaults to your active billing container (e.g., Free Trial).
- Resource Group: A logical container that groups related cloud resources together to simplify cost tracking, security auditing, and access control.
- Region: The physical geographic data center location (e.g., East US). Always select regions closest to your user base.
- Availability Zones: Fault-isolated data center locations within a region (Zone 1, Zone 2, Zone 3) ensuring high availability.
- Image: The OS template (e.g., Ubuntu Server 22.04 LTS). Selecting eligible free-tier images prevents unexpected charges.
- Architecture: CPU instruction set (
x64vs.ARM).x64is standard for general workloads. - Azure Spot Discount:
- Mechanism: Azure leverages excess, unused capacity across its global data center fleet and offers them at steep discounts.
- Trade-off: Azure can evict (reclaim) these resources at any moment if compute demand spikes. Never use Spot VMs for production workloads. They are exclusively suited for Dev/Test and proof-of-concept (PoC) environments.
3. Comprehensive Breakdown of Azure VM Series & Workload Matching
Choosing the correct VM family prevents resource bottlenecks and keeps cloud expenditure optimized. Azure categorizes VMs into specific series based on workload requirements:
4. Connecting to an Azure Linux VM via SSH
To manage a newly provisioned Ubuntu VM securely, administrators use the SSH protocol backed by an RSA/PEM private key pair.
Step-by-Step Connection Workflow
- Download the Private Key: During VM creation, download and save the generated
.pemprivate key file (e.g.,first_VM.pem) to your local machine (typically in theDownloadsfolder). - Launch an Appropriate Terminal:
- Windows: Use Git Bash (recommended to natively run standard Linux SSH and permission commands).
- macOS / Linux: Use iTerm2 or the built-in terminal.
- Fix Private Key Permissions (Crucial Security Step):
Linux SSH clients reject private key files if their access permissions are overly permissive. Run the following command in Git Bash to restrict read access to the owner only:
BASH
chmod 600 /c/Users/abishek/Downloads/first_VM.pem - Execute the SSH Connection Command:
BASH
ssh -i "/c/Users/abishek/Downloads/first_VM.pem" azureuser@<YOUR_VM_PUBLIC_IP>
5. Deploying Jenkins on an Ubuntu Azure VM
Once connected to the remote Linux environment, you can install real-world DevOps tooling such as Jenkins.
Step 1: Update System Package Repositories
Every Linux distribution relies on a package manager to fetch software. First, refresh the local package index:
sudo apt update
Step 2: Install Java (Prerequisite)
Jenkins is a Java-based application and requires the Java Runtime Environment (JRE) to execute. Install OpenJDK via the apt package manager:
sudo apt install openjdk-17-jdk -y
Verify the installation:
java -version
Step 3: Install and Start Jenkins
Execute the official package repository scripts to install Jenkins on Ubuntu:
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | \
sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt update
sudo apt install jenkins -y
Step 4: Verify the Running Process & Port
Check if the Jenkins daemon is active and identify its default listening port:
ps -ef | grep jenkins
Observation: Jenkins runs as a background process and binds itself to Port
8080.
6. Configuring Network Security Groups (NSGs) & Inbound Ports
If you attempt to access http://<VM_PUBLIC_IP>:8080 from your local web browser immediately after installation, the connection will time out.
Why Does This Happen? (Cloud Security Reality)
By default, cloud security guardrails block all inbound traffic to virtual machines except for mandatory management ports (like Port 22 for SSH). To expose web applications, you must explicitly configure Network Security Group (NSG) Inbound Rules.
Steps to Open Port 8080 in Azure Portal
- Navigate to your virtual machine dashboard in the Azure Portal.
- Select Networking from the left-hand menu.
- Click Create inbound port rule.
- Configure the rule parameters:
- Source:
Any(allows traffic from any external network). - Source port ranges:
* - Destination:
Any - Service:
Custom - Destination port ranges:
8080 - Protocol:
Any - Action:
Allow - Priority:
400(lower numbers evaluate with higher precedence) - Name:
Allow-Jenkins-8080
- Source:
- Click Add.
Once the NSG rule is applied, refreshing your browser at http://<PUBLIC_IP>:8080 instantly loads the Jenkins unlock/setup screen.
7. Introduction to Virtual Machine Scale Sets (VMSS)
While creating standalone VMs is ideal for static workloads, modern web applications experience volatile traffic spikes.
The Problem with Static VMs
If a standalone VM running Jenkins or an e-commerce application handles 1,000 requests smoothly, a sudden surge of 10,000 concurrent users will overwhelm the CPU and RAM, causing the application to crash.
The Virtual Machine Scale Set (VMSS) Solution
- Auto-Scaling Architecture: VMSS allows you to automatically scale the number of VM instances up or down based on resource utilization metrics (e.g., CPU load >
75%) or scheduled time frames. - Built-In Load Balancing: Incoming traffic is automatically distributed across all active VM instances in the scale set.
- Cost Efficiency: When traffic drops during off-peak hours, VMSS automatically de-allocates unneeded instances, reducing cloud spend. (Note: AWS refers to this equivalent architectural pattern as Auto Scaling Groups (ASG)).
8. Summary and Key Takeaways
- Virtualization Core: Physical servers are partitioned using a hypervisor to maximize hardware utilization and lower infrastructure costs.
- ARM Integration: The Azure Resource Manager provisions VMs statically or dynamically based on user configurations submitted through the portal or CLI.
- Billing Safety: Free tier accounts will not incur unexpected charges unless you explicitly consent to upgrade to a Pay-As-You-Go subscription after 30 days.
- Spot Instances: Spot VMs offer heavily discounted pricing on unused data center capacity but lack uptime guarantees, making them strictly suited for Dev/Test environments.
- Workload-Driven Sizing: Selecting the correct VM series (
Bfor bursts,Dfor general purpose,Efor memory-heavy Redis,Lfor storage-heavy databases) is critical for application performance. - SSH Key Hygiene: Linux virtual machines secured via PEM private keys require strict file permission tightening (
chmod 600) before establishing remote terminal connections. - Package Management: Ubuntu VMs utilize
aptto manage software packages, whereas Red Hat/CentOS distributions use package managers likeyum/dnf. - NSG Security Rules: Cloud firewalls block external web traffic by default; applications hosted on custom ports (like Jenkins on
8080) require explicit Inbound Security Rules to be accessible over the internet. - Virtual Machine Scale Sets (VMSS): VMSS provides automatic horizontal scaling and load balancing to seamlessly handle unpredictable, high-volume production traffic spikes.