Scenario 01: LAMP Migration to Azure IaaS
📋 Project Definition
Section titled “📋 Project Definition”Business Context: As part of a modernization initiative, a legacy web workload (LAMP Stack) needs to be migrated to the public cloud. The objective is to reduce the operational overhead of physical hardware while maintaining full control over the operating system configuration.
Technical Requirements:
- Resource Isolation: Implementation of a dedicated Resource Group for lifecycle management.
- Network Security: Segmentation via VNET and strict traffic filtering (NSG) allowing only HTTP (80) and SSH (22).
- Compute Efficiency: Provisioning of a
Standard_B1s(Burstable) instance on Ubuntu 22.04 LTS. - Automation (Infrastructure as Code): Provisioning must be unattended, utilizing Cloud-Init for software stack configuration upon first boot.
🔧 Implementation Procedure (Azure CLI)
Section titled “🔧 Implementation Procedure (Azure CLI)”Execution via az cli to ensure deployment reproducibility and auditability.
-
Environment Variable Definition
Standardizing naming conventions for resources.
Ventana de terminal RG_NAME="rg-lamp-migration-001"LOCATION="northeurope"VM_NAME="vm-web-legacy-01"VNET_NAME="vnet-prod-01"NSG_NAME="nsg-web-public" -
Logical Container Creation
Ventana de terminal az group create --name $RG_NAME --location $LOCATION -
Bootstrapping Configuration (Cloud-Init)
Defining the desired state of the operating system. This manifest installs dependencies and generates test files automatically.
cloud-init-lamp.txt #cloud-configpackage_upgrade: truepackages:- apache2- php- libapache2-mod-php- mysql-server- php-mysqlwrite_files:- content: |<?php phpinfo(); ?>path: /var/www/html/info.phpruncmd:- systemctl restart apache2- systemctl enable apache2 -
Infrastructure Deployment
Atomic command that provisions network, security, public IP, and compute, injecting the Cloud-Init configuration.
Ventana de terminal az vm create \--resource-group $RG_NAME \--name $VM_NAME \--image Ubuntu2204 \--admin-username azureuser \--generate-ssh-keys \--public-ip-sku Standard \--size Standard_B1s \--custom-data @cloud-init-lamp.txt \--nsg $NSG_NAME -
Network Hardening (NSG)
Explicit configuration of inbound rules to allow web traffic.
Ventana de terminal az network nsg rule create \--resource-group $RG_NAME \--nsg-name $NSG_NAME \--name Allow-HTTP \--protocol Tcp \--priority 100 \--destination-port-range 80 \--access Allow -
Service Verification
Validation of the public endpoint availability.
Ventana de terminal IP_ADDRESS=$(az vm show -d -g $RG_NAME -n $VM_NAME --query publicIps -o tsv)echo "Endpoint available at: http://$IP_ADDRESS/info.php"
🔍 Design Decision
Section titled “🔍 Design Decision”Why Cloud-Init for this scenario?
Section titled “Why Cloud-Init for this scenario?”For single instance or base image deployments, Cloud-Init is the “Cloud-Native” industry standard. It removes the need for an external configuration server (like Ansible Tower) for the initial bootstrap, reducing complexity and Recovery Time Objective (RTO).