DEV Community

Cover image for โšก๏ธ Surviving Azureโ€™s Cloud Maze: DevOps Disaster Recovery, Network Wizardry & Bare-Metal Deployments [Week-6] ๐ŸŒฉ๏ธ
Suvrajeet Banerjee
Suvrajeet Banerjee Subscriber

Posted on

โšก๏ธ Surviving Azureโ€™s Cloud Maze: DevOps Disaster Recovery, Network Wizardry & Bare-Metal Deployments [Week-6] ๐ŸŒฉ๏ธ

This week marked a pivotal moment in my DevOps journey - diving deep into yet another Public Cloud Provider a.k.a. Microsoft Azure's cloud ecosystem and tackling complex infrastructure challenges that pushed my technical skills to new heights. From deploying React applications to architecting three-tier networks along-side managing full-stack applications with databases, Week 6 delivered hands-on experience bridging the gap between theoretical knowledge and real-world production environments that too using yet another Cloud Provider other than AWS.


๐ŸŽฏ Understanding Azure's Cloud Computing Foundation ๐Ÿ—๏ธ

What Makes Azure Special in the Cloud Landscape?

Microsoft Azure represents one of the world's leading cloud computing platforms, offering Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) solutions. Unlike traditional on-premises infrastructure, Azure provides on-demand computing resources that scales dynamically based on application requirements & needs.

๐Ÿงต Key Azure Advantages:

  • ๐ŸŒ Global Infrastructure: Over 60 regions worldwide with multiple availability zones
  • ๐Ÿ’ฐ Pay-as-you-use model: Only pay for resources consumed
  • ๐Ÿ”’ Enterprise Security: Built-in compliance and security frameworks
  • ๐Ÿš€ Rapid Scaling: Auto-scaling capabilities for varying workloads

๐Ÿงต Azure Compute Services Ecosystem

Azure offers diverse compute options, each serving specific use cases:

Virtual Machines (IaaS)

Virtual machines provide the maximum control and flexibility, allowing complete customization of the operating system and applications. They're ideal for:

  • ๐Ÿ“Š Legacy Application Migration: Lift-and-shift scenarios
  • ๐Ÿ”ง Custom Configurations: Specific software requirements
  • ๐Ÿ’พ Full OS Control: Complete administrative access

App Services (PaaS)

Platform-as-a-Service offerings that abstracts infrastructure management:

  • ๐ŸŽฏ Focus on Code: No requiremetnt for infrastructure management
  • ๐Ÿ”„ Auto-scaling: Built-in scaling capabilities
  • ๐Ÿ›ก๏ธ Security Updates: Automatic patching and updates

vm


๐Ÿš€ Deploying React Applications on Azure VMs ๐Ÿ’ป

๐Ÿงต The React Deployment Challenge

React applications require a specific deployment strategy because they're Single Page Applications (SPAs) that need proper web server configuration for client-side routing. This section demonstrates & imitates production React deployments on Azure infrastructure.

Step 1: Azure VM Provisioning

Creating an Ubuntu 24.04 LTS virtual machine involved several critical decisions:

VM Configuration Analysis:

  • Size Selection: B1s (1 vCPU, 1 GB RAM) - cost-effective for learning environments
  • Authentication: SSH keys provide better security than passwords
  • Storage: Premium SSD for faster I/O operations

Step 2: Development Stack Installation

The deployment requires a complete development environment setup:

# System updates
sudo apt update && sudo apt upgrade -y

# Node.js 18.x LTS installation via NodeSource
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

# Nginx web server installation
sudo apt install -y nginx
Enter fullscreen mode Exit fullscreen mode

ssh

Step 3: React Application Build Process

Understanding the React build process is crucial for production deployments:

# Clone the application
git clone https://github.com/suvrajeetbanerjee/my-react-app.git
cd my-react-app

# Install dependencies
npm install

# Create production build
npm run build
Enter fullscreen mode Exit fullscreen mode

Why Building is Essential:

  • ๐Ÿ“ฆ Code Optimization: Minification and bundling reduce file sizes
  • ๐Ÿš€ Performance: Optimized assets load faster
  • ๐Ÿ”’ Security: Source code is compiled and obfuscated

Step 4: Nginx Configuration for SPAs

Single Page Applications(SPA) requires special web server configuration to handle client-side routing:

server {
    listen 80 default_server;
    root /home/azureuser/my-react-app/build;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }
}
Enter fullscreen mode Exit fullscreen mode

Critical Configuration Elements:

  • ๐ŸŽฏ try_files directive: Enables client-side routing by falling back to index.html
  • ๐Ÿ“ root directive: Points to the React build directory
  • ๐ŸŒ index directive: Specifies the default file to serve

๐Ÿงต Overcoming the 500 Internal Server Error Challenge

err

The most valuable learning experience came from troubleshooting a critical production error. The application was built successfully, Nginx was running, but the dreaded 500 Internal Server Error appeared.

Root Cause Analysis:

# Error log investigation revealed
sudo tail -f /var/log/nginx/error.log
# Output: stat() "/home/azureuser/my-react-app/build" failed (13: Permission denied)
Enter fullscreen mode Exit fullscreen mode

The Permission Problem:
Nginx runs as the www-data user, but couldn't access files in the user's home directory due to restrictive permissions. This helps revisit concepts about Unix file permissions and web server security models.

Solution Implementation:

# Fix directory permissions
sudo chmod 755 /home
sudo chmod 755 /home/azureuser
sudo chmod 755 /home/azureuser/my-react-app

# Add www-data to user group
sudo usermod -a -G azureuser www-data

# Verify access
sudo -u www-data stat /home/azureuser/my-react-app/build
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก This challenge reinforces the importance of understanding Linux permissions, web server architecture, along with systematic troubleshooting approaches.

react


๐Ÿ—๏ธ Three-Tier Network Architecture with Load Balancer ๐ŸŒ

๐Ÿงต Understanding Network Architecture Fundamentals

Three-tier architecture represents a fundamental design pattern in enterprise applications, providing separation of concerned layers across presentation, application, and data layers.

Network Design Principles

Subnet Planning Strategy:
Azure reserves 5 IP addresses per subnet, making proper CIDR planning essential:

VNet: 10.0.0.0/16 (65,536 available addresses)
โ”œโ”€โ”€ Web Subnet: 10.0.1.0/24 (251 usable addresses)
โ”œโ”€โ”€ App Subnet: 10.0.2.0/25 (123 usable addresses) 
โ””โ”€โ”€ DB Subnet: 10.0.3.0/26 (59 usable addresses)
Enter fullscreen mode Exit fullscreen mode

3ta

Network Security Groups (NSG) Deep Dive

NSGs function as virtual firewalls, controlling traffic at the subnet and network interface level. Understanding NSG rule evaluation is crucial for security:

Rule Processing Logic:

  1. Priority-based: Lower numbers are processed first (100-4096)
  2. First Match Wins: Processing stops at first matching rule
  3. Default Deny: Implicit deny rules at the end

Critical NSG Best Practices:

IP Address Range Configuration:
One of the most important lessons involves NSG source IP configuration. Instead of using /32 (single IP), it's better to use /24 ranges for dynamic IP scenarios:

# Problem: Dynamic ISP IP changes break SSH access
Source: 185.43.167.32/32  # โŒ Breaks when ISP changes IP

# Solution: Use broader range for ISP dynamic allocation
Source: 185.43.167.0/24   # โœ… Accommodates ISP IP changes
Enter fullscreen mode Exit fullscreen mode

Why /24 is Superior:

  • ๐Ÿ”„ Dynamic IP Resilience: ISPs often allocate IPs within the same /24 range
  • ๐Ÿ“Š Usable Address Range: /24 provides 254 usable addresses vs. 0 for /32
  • ๐Ÿ›ก๏ธ Operational Reliability: Reduces connection failures due to IP changes

๐Ÿ’ก *This insight came directly from experiencing SSH connection failures when my ISP changed my dynamic IP address.(

Azure Load Balancer Implementation

lb

Azure Load Balancer operates at Layer 4 (TCP/UDP), distributing incoming traffic across healthy backend instances:

Load Balancer Components:

  • ๐ŸŽฏ Frontend IP: Public IP address receiving traffic
  • ๐Ÿ”— Backend Pool: Collection of VMs receiving distributed traffic
  • ๐Ÿฅ Health Probe: Monitors backend instance health
  • โš–๏ธ Load Balancing Rules: Defines traffic distribution logic

Health Probe Configuration:

Protocol: TCP
Port: 80
Interval: 5 seconds
Unhealthy Threshold: 2 failures
Enter fullscreen mode Exit fullscreen mode

Health probes ensure traffic only routes to functional instances, providing automatic failover capabilities.


๐Ÿ“š EpicBook Full-Stack Application with MySQL ๐Ÿ—„๏ธ

๐Ÿงต Full-Stack Application Architecture

The EpicBook application represents a complete three-tier architecture implementation:

  • Frontend: Static files served by Nginx
  • Backend: Node.js API server (port 3001)
  • Database: MySQL server for data persistence

eb

Application Deployment Strategy

Node.js Backend Configuration:

// Database connection configuration
{
  "development": {
    "username": "epicbooksadmin",
    "password": "EBAdmn123",
    "database": "bookstore",
    "host": "127.0.0.1",
    "dialect": "mysql"
  }
}
Enter fullscreen mode Exit fullscreen mode

Nginx Reverse Proxy Setup:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;

    # Frontend (React build)
    root /home/azureuser/theepicbook/frontend/build;
    index index.html;

    location / {
        try_files $uri /index.html;
    }

    # Backend API proxy (change 3001 if your backend uses a different port)
    location /api/ {
        proxy_pass http://127.0.0.1:3001/;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
    }
}
Enter fullscreen mode Exit fullscreen mode

MySQL Database Management

Database Setup Process:

# MySQL security configuration
sudo mysql_secure_installation

# Database and user creation
mysql -u root -p
CREATE DATABASE bookstore;
CREATE USER 'epicbooksadmin'@'localhost' IDENTIFIED BY 'EBAdmn123';
GRANT ALL PRIVILEGES ON bookstore.* TO 'epicbooksadmin'@'localhost';
FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

Azure MySQL Flexible Server Challenge

A significant learning experience involved attempting to deploy Azure Database for MySQL Flexible Server. Despite extensive troubleshooting, I encountered persistent provisioning errors:

Error Encountered:

Code="ProvisionNotSupportedForRegion" 
Message="Provisioning in requested region is not supported."
Enter fullscreen mode Exit fullscreen mode

Root Cause Analysis:
The issue stemmed from Azure free tier limitations and regional restrictions for MySQL Flexible Server resources. Even after 30+ hours of debugging and submitting support tickets, the service remained unavailable.

Solution Adaptation:
Instead of abandoning the project, I pivoted to installing MySQL directly on the VM:

# Local MySQL installation
sudo apt install -y mysql-server mysql-client
sudo systemctl start mysql
sudo systemctl enable mysql
Enter fullscreen mode Exit fullscreen mode

This challenge taught valuable lessons about:

  • ๐Ÿ”„ Solution Adaptability: Finding alternatives when cloud services aren't available
  • ๐Ÿ› ๏ธ Local vs. Managed Services: Trade-offs between convenience and control
  • ๐Ÿ’ฐ Cost Management: Understanding service limitations in free tiers

๐Ÿ”’ Security and Best Practices Reflections ๐Ÿ›ก๏ธ

๐Ÿงต Network Security Implementation

NSG Rule Optimization:

  • โœ… Principle of Least Privilege: Only open required ports
  • ๐ŸŽฏ Source Restriction: Use specific IP ranges instead of "Any"
  • ๐Ÿ“Š Rule Documentation: Clear naming conventions for maintainability

SSH Key Management:

  • ๐Ÿ”‘ Key-based Authentication: More secure than passwords
  • ๐Ÿ›ก๏ธ Proper Permissions: chmod 400 for private keys
  • ๐Ÿ”’ Key Rotation: Regular key updates for enhanced security

Application Security Considerations

File Permissions Management:
Understanding Unix permissions is crucial for web application deployment:

  • ๐Ÿ“ Directory Permissions: 755 allows read/execute access
  • ๐Ÿ“„ File Permissions: 644 provides read access for web servers
  • ๐Ÿ‘ฅ Group Management: Adding web server users to appropriate groups

๐Ÿ’ฐ Cost Management and Resource Optimization ๐Ÿ’ก

๐Ÿงต Azure Cost Control Strategies

Resource Lifecycle Management:

  • ๐Ÿ—‘๏ธ Immediate Cleanup: Delete resources after testing
  • ๐Ÿ“Š Resource Monitoring: Use Azure Cost Management tools
  • โฐ Scheduled Shutdowns: Auto-shutdown for non-production VMs

ap

Cost-Effective Configurations:

  • ๐Ÿ’ป VM Sizing: B1s instances for learning environments
  • ๐Ÿ’พ Storage Optimization: Standard SSD instead of Premium when appropriate
  • ๐ŸŒ Region Selection: Choose regions with lower pricing

Resource Group Strategy

Using resource groups effectively enables:

  • ๐Ÿงน Bulk Deletion: Remove all related resources simultaneously
  • ๐Ÿท๏ธ Cost Tracking: Monitor spending by project or environment
  • ๐Ÿ” Access Control: Apply RBAC policies consistently

๐Ÿ”ง Troubleshooting Methodologies Developed ๐Ÿ”

๐Ÿงต Systematic Problem-Solving Approach

1. Error Log Analysis:

# Nginx error logs
sudo tail -f /var/log/nginx/error.log

# System logs  
sudo journalctl -u nginx -f

# Application logs
node server.js 2>&1 | tee app.log
Enter fullscreen mode Exit fullscreen mode

2. Network Connectivity Testing:

# Test local connectivity
curl http://localhost

# Test external access
curl http://VM-PUBLIC-IP

# Port availability check
netstat -tlnp | grep :80
Enter fullscreen mode Exit fullscreen mode

3. Permission Verification:

# Test file access as web server user
sudo -u www-data stat /path/to/files

# Verify directory permissions
ls -la /home/azureuser/
Enter fullscreen mode Exit fullscreen mode

๐ŸŽ“ Key Learning Outcomes for Technical Growth ๐Ÿš€

๐Ÿงต Infrastructure Skills Acquired

Azure Platform Mastery:

  • โ˜๏ธ Resource Management: Creating and configuring VMs, NSGs, Load Balancers
  • ๐ŸŒ Network Architecture: Three-tier design patterns and security groups
  • ๐Ÿ”ง Service Integration: Connecting multiple Azure services effectively

Linux System Administration:

  • ๐Ÿ–ฅ๏ธ Server Management: Package installation, service configuration
  • ๐Ÿ” Permission Management: Unix file permissions and user groups
  • ๐Ÿ” Troubleshooting: Log analysis and systematic problem resolution

Application Deployment Expertise

Web Server Configuration:

  • ๐ŸŒ Nginx Mastery: Reverse proxy setup, static file serving
  • โš™๏ธ Process Management: Service startup, monitoring, and debugging
  • ๐Ÿ”ง Performance Optimization: Gzip compression, caching strategies & PM2 (production-ready process manager for Node.js applications.

Database Integration:

  • ๐Ÿ—„๏ธ MySQL Administration: Installation, user management, security
  • ๐Ÿ”— Application Connectivity: Database connection configuration
  • ๐Ÿ› ๏ธ Troubleshooting: Connection issues and permission problems

DevOps Practices Internalized

Infrastructure as Code Mindset:

  • ๐Ÿ“‹ Documentation: Comprehensive step-by-step procedures
  • ๐Ÿ”„ Reproducibility: Scripted deployments and configurations
  • ๐Ÿงน Resource Management: Proper cleanup and cost control

๐Ÿ”ฎ Next Steps and Advanced Concepts ๐ŸŒŸ

๐Ÿงต Upcoming Learning Objectives

Based on this week's foundation, the next learning phase will focus on:

Automation and Orchestration:

  • ๐Ÿค– Infrastructure as Code: ARM templates and Terraform
  • ๐Ÿ”„ CI/CD Pipelines: Azure DevOps and GitHub Actions
  • ๐Ÿณ Containerization: Docker and Azure Container Instances

Advanced Networking:

  • ๐ŸŒ Virtual Network Peering: Cross-region connectivity
  • ๐Ÿ›ก๏ธ Azure Firewall: Advanced threat protection
  • ๐Ÿ“Š Network Monitoring: Traffic analysis and optimization

Scalability and Performance:

  • ๐Ÿ“ˆ Auto-scaling: VM Scale Sets and Application Gateway
  • ๐Ÿ’พ Caching Strategies: Redis and CDN implementation
  • ๐Ÿ“Š Monitoring: Application Insights and Azure Monitor

๐Ÿงต Production Readiness Considerations

Security Enhancements:

  • ๐Ÿ” Key Vault Integration: Secure secret management
  • ๐ŸŒ SSL/TLS Configuration: HTTPS implementation
  • ๐Ÿ›ก๏ธ WAF Deployment: Web Application Firewall protection

High Availability Design:

  • ๐ŸŒ Multi-Region Deployment: Geographic redundancy
  • ๐Ÿ’พ Database Replication: Master-slave configurations
  • ๐Ÿ”„ Backup Strategies: Automated backup and recovery

๐Ÿ Conclusion: Building Production-Ready Skills ๐Ÿ’ช

Week 6 of the DevOps journey provided invaluable hands-on experience with Microsoft Azure's cloud ecosystem. From deploying React applications to architecting three-tier networks & managing full-stack applications with databases โ€” each blogs, documentations & posts that builds upon previous knowledge while introducing new challenges building an unshakeable foundation.

The most significant learning came not from successful deployments, but from overcoming obstacles like permission issues, MySQL service limitations, and network configuration challenges. These real-world problems teaches systematic troubleshooting approaches, adaptability, and the importance of understanding underlying infrastructure concepts.

Key Takeaways:

  • ๐ŸŽฏ Practical Experience: Hands-on learning beats theoretical knowledge
  • ๐Ÿ” Problem-Solving: Systematic approaches to complex issues
  • ๐Ÿ“š Documentation: Detailed records enable knowledge retention
  • ๐Ÿ’ฐ Cost Awareness: Cloud resource management is crucial
  • ๐Ÿ”’ Security First: Proper configuration prevents vulnerabilities

๐ŸŽฏ This blog marks the end of Week 6 of 12 of the free DevOps cohort organized by Pravin Mishra sir ๐Ÿ™, building upon ๐Ÿ—๏ธ Infrastructure as Code Mastery: From Manual Chaos to CloudFormation Symphony [Week-5]โ˜๏ธโšก from the DevOps Series โ€” documenting my complete leanring journey from fundamentals to advanced implementations.

๐Ÿ”— You can start your DevOps journey for free from Pravin's comprehensive YouTube Playlist.


๐Ÿท๏ธ Tags:

#Azure #DevOps #MySQL #CloudComputing #ProblemSolving #NodeJS #WebDevelopment #CloudArchitecture #TechnicalChallenges #LearningJourney #DatabaseManagement #CloudSolutions #TechStruggles #DevOpsCommunity #Networking #VirtualMachines #React #TechnicalLearning #CloudSecurity #LoadBalancers #NSG #SystemAdministration #ProfessionalDevelopment #TechSkills #ContinuousLearning #CloudArchitecture


Top comments (0)