☁️ Running AlmaLinux on Azure: Complete Cloud Deployment Guide
Welcome to the enterprise cloud revolution! 🚀 Today we’ll master deploying AlmaLinux on Microsoft Azure, combining the stability of enterprise Linux with the power of Microsoft’s global cloud platform. Think of this as building your digital empire in the sky - scalable, secure, and cost-effective! 🏢
With Red Hat’s licensing changes, enterprises worldwide are embracing AlmaLinux as their go-to enterprise Linux distribution. Running it on Azure gives you the best of both worlds: enterprise-grade Linux without vendor lock-in, plus Microsoft’s world-class cloud infrastructure. Let’s unlock this powerful combination! 💪
🤔 Why Run AlmaLinux on Azure?
AlmaLinux on Azure is a game-changer for enterprise computing! ⚡ Here’s why this combination dominates:
- 💰 Cost Savings - No Red Hat subscription fees, pay only for Azure resources
- 🌍 Global Reach - Deploy across 60+ Azure regions worldwide
- 🏢 Enterprise Ready - Production support from both CloudLinux and Microsoft
- ⚡ Massive Scale - Scale from single VMs to thousands of instances
- 🔒 Security First - Azure Security Center + AlmaLinux security features
- 🤝 Hybrid Integration - Seamlessly integrate with on-premises systems
- 📊 Cost Optimization - Reserved instances, spot pricing, and auto-scaling
- 🛠️ DevOps Ready - Perfect for CI/CD, containers, and modern workloads
🎯 What You Need
Before launching AlmaLinux in the Azure cloud, ensure you have:
✅ Azure subscription (free tier available for learning)
✅ Basic cloud computing knowledge (we’ll guide you through everything!)
✅ SSH client (built into Windows 10+, macOS, and Linux)
✅ Azure CLI installed (or use Azure Cloud Shell)
✅ Credit card for Azure billing (free tier includes $200 credit)
✅ Text editor for configuration files
✅ Basic Linux knowledge (helpful but not required)
✅ 10-15 minutes to create your first AlmaLinux VM
📝 Setting Up Azure Environment
Let’s prepare your Azure environment for AlmaLinux! 🛠️
Install Azure CLI
# Install Azure CLI on Windows (PowerShell)
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi
Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
# Downloads and installs Azure CLI on Windows
# Install Azure CLI on macOS
brew update && brew install azure-cli
# Uses Homebrew package manager
# Install Azure CLI on Linux (Ubuntu/Debian)
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# Official installation script
# Install on AlmaLinux/RHEL/CentOS
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/azure-cli.repo
sudo dnf install azure-cli
# Installs Azure CLI using DNF package manager
# Verify installation
az --version
# Should show Azure CLI version information
Login and Set Up Subscription
# Login to Azure
az login
# Opens browser for authentication
# List your subscriptions
az account list --output table
# Shows all available Azure subscriptions
# Set active subscription (if you have multiple)
az account set --subscription "Your-Subscription-Name"
# Sets the default subscription for commands
# Verify current subscription
az account show --output table
# Shows active subscription details
# Create resource group for AlmaLinux resources
az group create --name AlmaLinux-RG --location eastus
# Creates resource group in East US region
# Other popular regions: westus2, westeurope, southeastasia
🔧 Creating Your First AlmaLinux VM
Let’s launch AlmaLinux on Azure! 🚀
Find AlmaLinux Images
# List available AlmaLinux images
az vm image list --publisher almalinux --output table --all
# Shows all AlmaLinux versions available on Azure
# Get specific AlmaLinux 9 image information
az vm image list --publisher almalinux --offer almalinux --sku 9_x --output table --all
# Shows AlmaLinux 9 versions with URNs
# Show image details
az vm image show --urn almalinux:almalinux:9_x:latest
# Displays detailed information about the latest AlmaLinux 9 image
Create Virtual Machine
# Create AlmaLinux VM with basic configuration
az vm create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-VM-01 \
--image almalinux:almalinux:9_x:latest \
--admin-username azureuser \
--generate-ssh-keys \
--size Standard_B2s \
--location eastus \
--public-ip-sku Standard \
--storage-sku Premium_LRS
# Creates a Standard_B2s VM with SSD storage
# Create production-ready VM with more resources
az vm create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-Prod-01 \
--image almalinux:almalinux:9_x:latest \
--admin-username azureuser \
--authentication-type ssh \
--ssh-key-values ~/.ssh/id_rsa.pub \
--size Standard_D4s_v3 \
--os-disk-size-gb 128 \
--storage-sku Premium_LRS \
--accelerated-networking true \
--location eastus
# Creates a high-performance VM with 4 vCPUs and 16GB RAM
# Show VM details
az vm show --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --output table
# Displays VM configuration and status
Configure Network Security
# Create Network Security Group for web servers
az network nsg create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-Web-NSG \
--location eastus
# Creates network security group
# Allow SSH (port 22)
az network nsg rule create \
--resource-group AlmaLinux-RG \
--nsg-name AlmaLinux-Web-NSG \
--name Allow-SSH \
--protocol Tcp \
--priority 1000 \
--destination-port-ranges 22 \
--access Allow \
--direction Inbound
# Opens SSH port for remote access
# Allow HTTP (port 80)
az network nsg rule create \
--resource-group AlmaLinux-RG \
--nsg-name AlmaLinux-Web-NSG \
--name Allow-HTTP \
--protocol Tcp \
--priority 1010 \
--destination-port-ranges 80 \
--access Allow \
--direction Inbound
# Opens HTTP port for web traffic
# Allow HTTPS (port 443)
az network nsg rule create \
--resource-group AlmaLinux-RG \
--nsg-name AlmaLinux-Web-NSG \
--name Allow-HTTPS \
--protocol Tcp \
--priority 1020 \
--destination-port-ranges 443 \
--access Allow \
--direction Inbound
# Opens HTTPS port for secure web traffic
# Apply NSG to VM's network interface
az vm show --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --query "networkProfile.networkInterfaces[0].id" --output tsv
# Gets network interface ID
az network nic update \
--resource-group AlmaLinux-RG \
--name AlmaLinux-VM-01VMNic \
--network-security-group AlmaLinux-Web-NSG
# Applies security group to VM
🌟 Initial AlmaLinux Configuration
Let’s configure your AlmaLinux VM for production use! ✅
Connect and Update System
# Get VM's public IP address
az vm show --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --show-details --query publicIps --output tsv
# Returns the public IP address
# SSH into your AlmaLinux VM
ssh azureuser@YOUR_VM_PUBLIC_IP
# Replace YOUR_VM_PUBLIC_IP with actual IP
# Once connected, update the system
sudo dnf update -y
# Updates all packages to latest versions
# Install essential packages
sudo dnf install -y wget curl vim git htop neofetch
# Installs common administrative tools
# Configure automatic updates
sudo dnf install -y dnf-automatic
sudo systemctl enable --now dnf-automatic.timer
# Enables automatic security updates
# Check system information
neofetch
# Shows system details with AlmaLinux branding
# Verify Azure integration
sudo dmesg | grep -i azure
# Shows Azure-related kernel messages
Install Azure Linux Agent
# The Azure Linux Agent should already be installed, but let's verify
rpm -qa | grep WALinux
# Should show walinuxagent package
# If not installed, install it
sudo dnf install -y WALinuxAgent
# Installs Azure Linux Agent
# Enable and start the agent
sudo systemctl enable walinuxagent
sudo systemctl start walinuxagent
# Ensures Azure integration works properly
# Check agent status
sudo systemctl status walinuxagent
# Should show "active (running)"
# View agent logs
sudo journalctl -u walinuxagent --no-pager
# Shows Azure agent activity logs
Configure Monitoring and Logging
# Install Azure Monitor Agent (optional but recommended)
wget https://aka.ms/azcmagent -O ~/install_linux_azcmagent.sh
bash ~/install_linux_azcmagent.sh
# Downloads and installs Azure monitoring
# Configure rsyslog for centralized logging
echo '*.* @@your-log-server:514' | sudo tee -a /etc/rsyslog.conf
sudo systemctl restart rsyslog
# Configures remote logging (replace with your log server)
# Set up log rotation
echo '/var/log/messages {
weekly
rotate 4
compress
delaycompress
missingok
notifempty
create 0644 root root
}' | sudo tee /etc/logrotate.d/messages
# Configures automatic log rotation
🎮 Quick Examples
Let’s explore practical Azure deployment scenarios! 🎯
Example 1: Web Server Deployment
# Install and configure Nginx
sudo dnf install -y nginx
sudo systemctl enable --now nginx
# Installs and starts Nginx web server
# Create a simple test page
echo "<h1>🚀 AlmaLinux on Azure!</h1>
<p>This AlmaLinux server is running on Microsoft Azure!</p>
<p>Server Details:</p>
<ul>
<li>OS: $(cat /etc/redhat-release)</li>
<li>Kernel: $(uname -r)</li>
<li>Uptime: $(uptime)</li>
</ul>" | sudo tee /var/www/html/index.html
# Creates a custom welcome page
# Configure firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
# Opens HTTP and HTTPS ports
# Test the web server
curl http://localhost
# Should display your custom page
# Get VM's public IP and test externally
VM_IP=$(az vm show --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --show-details --query publicIps --output tsv)
echo "Access your website at: http://$VM_IP"
Example 2: Load Balancer Setup
# Create availability set for multiple VMs
az vm availability-set create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-AvailabilitySet \
--platform-fault-domain-count 2 \
--platform-update-domain-count 5
# Creates availability set for high availability
# Create additional VMs in availability set
for i in {2..3}; do
az vm create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-VM-0$i \
--image almalinux:almalinux:9_x:latest \
--admin-username azureuser \
--generate-ssh-keys \
--size Standard_B2s \
--availability-set AlmaLinux-AvailabilitySet \
--public-ip-address "" \
--nsg ""
done
# Creates 2 additional VMs without public IPs
# Create load balancer
az network lb create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-LoadBalancer \
--public-ip-address AlmaLinux-LB-PublicIP \
--frontend-ip-name AlmaLinux-FrontEnd \
--backend-pool-name AlmaLinux-BackEndPool
# Creates Azure Load Balancer
# Add VMs to backend pool
for i in {2..3}; do
az network nic ip-config address-pool add \
--resource-group AlmaLinux-RG \
--nic-name AlmaLinux-VM-0${i}VMNic \
--ip-config-name ipconfigAlmaLinux-VM-0$i \
--address-pool AlmaLinux-BackEndPool \
--lb-name AlmaLinux-LoadBalancer
done
# Adds VMs to load balancer backend pool
Example 3: Auto-Scaling Configuration
# Create Virtual Machine Scale Set
az vmss create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-ScaleSet \
--image almalinux:almalinux:9_x:latest \
--admin-username azureuser \
--generate-ssh-keys \
--instance-count 2 \
--vm-sku Standard_B2s \
--load-balancer AlmaLinux-ScaleSet-LB \
--backend-pool-name AlmaLinux-ScaleSet-BackEndPool
# Creates auto-scaling VM set
# Configure auto-scaling rules
az monitor autoscale create \
--resource-group AlmaLinux-RG \
--resource AlmaLinux-ScaleSet \
--resource-type Microsoft.Compute/virtualMachineScaleSets \
--name AlmaLinux-AutoScale \
--min-count 2 \
--max-count 10 \
--count 3
# Sets up basic auto-scaling
# Add scale-out rule (CPU > 70%)
az monitor autoscale rule create \
--resource-group AlmaLinux-RG \
--autoscale-name AlmaLinux-AutoScale \
--condition "Percentage CPU > 70 avg 5m" \
--scale out 1
# Scales out when CPU usage is high
# Add scale-in rule (CPU < 30%)
az monitor autoscale rule create \
--resource-group AlmaLinux-RG \
--autoscale-name AlmaLinux-AutoScale \
--condition "Percentage CPU < 30 avg 5m" \
--scale in 1
# Scales in when CPU usage is low
🚨 Fix Common Problems
Encountering issues? Here are solutions to common Azure problems:
Problem 1: SSH Connection Fails
# Check VM status
az vm get-instance-view --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --query instanceView.statuses --output table
# Shows VM power state
# Start VM if stopped
az vm start --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Powers on the virtual machine
# Check network security group rules
az network nsg rule list --resource-group AlmaLinux-RG --nsg-name AlmaLinux-Web-NSG --output table
# Lists all firewall rules
# Reset SSH configuration
az vm user reset-ssh --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Resets SSH daemon configuration
# Enable serial console access
az vm boot-diagnostics enable --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Enables console access through Azure portal
Problem 2: High Costs
# Check current VM pricing
az vm list-sizes --location eastus --output table | grep Standard_B
# Shows available B-series (burstable) VMs
# Resize VM to lower cost option
az vm deallocate --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
az vm resize --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --size Standard_B1s
az vm start --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Resizes to cheapest B-series VM
# Set up cost alerts
az consumption budget create \
--subscription-id $(az account show --query id --output tsv) \
--budget-name AlmaLinux-Budget \
--amount 100 \
--category Cost \
--time-grain Monthly \
--time-period-start $(date --date="first day of this month" +%Y-%m-01) \
--time-period-end $(date --date="last day of next month" +%Y-%m-%d)
# Creates $100 monthly budget alert
# Use spot instances for dev/test
az vm create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-Spot-VM \
--image almalinux:almalinux:9_x:latest \
--admin-username azureuser \
--generate-ssh-keys \
--size Standard_B2s \
--priority Spot \
--max-price 0.01
# Creates spot instance with $0.01/hour max price
Problem 3: Performance Issues
# Enable accelerated networking (requires VM restart)
az vm deallocate --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
az vm update --resource-group AlmaLinux-RG --name AlmaLinux-VM-01 --set networkProfile.networkInterfaces[0].enableAcceleratedNetworking=true
az vm start --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Enables SR-IOV for better network performance
# Upgrade to Premium SSD
az vm deallocate --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
az disk update --resource-group AlmaLinux-RG --name AlmaLinux-VM-01_OsDisk_1 --sku Premium_LRS
az vm start --resource-group AlmaLinux-RG --name AlmaLinux-VM-01
# Upgrades OS disk to Premium SSD
# Add data disk for better I/O
az vm disk attach --resource-group AlmaLinux-RG --vm-name AlmaLinux-VM-01 --name AlmaLinux-DataDisk --size-gb 128 --sku Premium_LRS --new
# Adds 128GB Premium SSD data disk
# On the VM, format and mount the new disk
sudo fdisk -l | grep /dev/sd
# Lists available disks
sudo mkfs.ext4 /dev/sdc
# Formats the new disk (adjust device name as needed)
sudo mkdir /data
sudo mount /dev/sdc /data
echo '/dev/sdc /data ext4 defaults 0 0' | sudo tee -a /etc/fstab
# Mounts disk and adds to fstab
Problem 4: Backup and Recovery
# Enable Azure Backup for VM
az backup vault create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-Backup-Vault \
--location eastus
# Creates backup vault
# Create backup policy
az backup policy create \
--resource-group AlmaLinux-RG \
--vault-name AlmaLinux-Backup-Vault \
--name AlmaLinux-Daily-Policy \
--policy '{
"backupManagementType": "AzureIaasVM",
"schedulePolicy": {
"schedulePolicyType": "SimpleSchedulePolicy",
"scheduleRunFrequency": "Daily",
"scheduleRunTimes": ["2021-12-17T23:00:00.000Z"]
},
"retentionPolicy": {
"retentionPolicyType": "LongTermRetentionPolicy",
"dailySchedule": {
"retentionTimes": ["2021-12-17T23:00:00.000Z"],
"retentionDuration": {
"count": 30,
"durationType": "Days"
}
}
}
}'
# Creates daily backup policy with 30-day retention
# Enable backup for VM
az backup protection enable-for-vm \
--resource-group AlmaLinux-RG \
--vault-name AlmaLinux-Backup-Vault \
--vm AlmaLinux-VM-01 \
--policy-name AlmaLinux-Daily-Policy
# Enables automatic daily backups
# Create manual backup
az backup protection backup-now \
--resource-group AlmaLinux-RG \
--vault-name AlmaLinux-Backup-Vault \
--container-name AlmaLinux-VM-01 \
--item-name AlmaLinux-VM-01 \
--backup-management-type AzureIaasVM
# Creates immediate backup
Problem 5: Security Hardening
# Enable Azure Security Center
az security auto-provisioning-setting update --name default --auto-provision On
# Enables automatic security agent deployment
# Configure disk encryption
az vm encryption enable \
--resource-group AlmaLinux-RG \
--name AlmaLinux-VM-01 \
--disk-encryption-keyvault AlmaLinux-KeyVault \
--volume-type All
# Encrypts OS and data disks
# Set up Azure Key Vault
az keyvault create \
--resource-group AlmaLinux-RG \
--name AlmaLinux-KeyVault \
--location eastus \
--enabled-for-disk-encryption true
# Creates key vault for encryption keys
# Configure Log Analytics workspace
az monitor log-analytics workspace create \
--resource-group AlmaLinux-RG \
--workspace-name AlmaLinux-LogAnalytics \
--location eastus
# Creates centralized logging workspace
📋 Simple Commands Summary
Here’s your Azure AlmaLinux quick reference! 📖
Command | Purpose | Example |
---|---|---|
az vm create | Create new VM | az vm create --name MyVM --image almalinux:almalinux:9_x:latest |
az vm list | List all VMs | az vm list --resource-group AlmaLinux-RG --output table |
az vm start/stop | Control VM power | az vm start --name AlmaLinux-VM-01 |
az vm show | Show VM details | az vm show --name AlmaLinux-VM-01 --show-details |
az vm resize | Change VM size | az vm resize --name AlmaLinux-VM-01 --size Standard_D2s_v3 |
az vm delete | Delete VM | az vm delete --name AlmaLinux-VM-01 --yes |
az account list-locations | List Azure regions | Shows all available Azure datacenters |
az vm list-sizes | Show VM sizes | az vm list-sizes --location eastus --output table |
💡 Tips for Success
Follow these best practices for AlmaLinux on Azure success! 🌟
☁️ Cost Optimization
- Use B-series VMs for development and testing
- Implement auto-shutdown schedules
- Use reserved instances for production
- Monitor spending with cost alerts
🔒 Security Best Practices
- Always use SSH keys instead of passwords
- Configure Network Security Groups properly
- Enable disk encryption for sensitive data
- Use Azure Security Center recommendations
📊 Performance Optimization
- Choose the right VM size for your workload
- Use Premium SSD for production workloads
- Enable accelerated networking when available
- Monitor performance with Azure Monitor
🏗️ Infrastructure as Code
- Use ARM templates or Terraform
- Version control your infrastructure
- Automate deployments with Azure DevOps
- Test infrastructure changes in staging
🔄 High Availability
- Deploy VMs across availability zones
- Use load balancers for traffic distribution
- Implement auto-scaling based on metrics
- Plan for disaster recovery
📈 Monitoring and Alerting
- Set up comprehensive monitoring
- Create meaningful alerts
- Use Log Analytics for centralized logging
- Implement application performance monitoring
🏆 What You Learned
Congratulations! You’ve mastered AlmaLinux on Azure! 🎉 Here’s what you accomplished:
✅ Set up Azure environment with CLI and subscriptions
✅ Created AlmaLinux VMs with proper sizing and configuration
✅ Configured networking and security with NSGs and firewall rules
✅ Implemented load balancing and auto-scaling for high availability
✅ Set up monitoring and backup for production reliability
✅ Optimized costs with appropriate VM sizing and scheduling
✅ Secured deployments with encryption and security best practices
✅ Troubleshot common issues like a cloud architect pro
🎯 Why This Matters
Running AlmaLinux on Azure represents the future of enterprise computing - open source freedom combined with enterprise-grade cloud infrastructure! 🌟
This combination gives you unprecedented flexibility: escape vendor lock-in while leveraging Microsoft’s global cloud platform. Whether you’re migrating from Red Hat due to licensing concerns, building new cloud-native applications, or creating hybrid infrastructures, AlmaLinux on Azure provides the perfect foundation.
You’re now equipped to build scalable, secure, and cost-effective infrastructure that can grow from startup to global enterprise. These skills are incredibly valuable as more organizations embrace cloud-first strategies and open source solutions! 🚀
Remember: the cloud is not just about technology - it’s about agility, innovation, and competitive advantage. By mastering AlmaLinux on Azure, you’re prepared to architect the next generation of enterprise applications! ⭐
Great job on completing this comprehensive Azure deployment guide! You’re now ready to deploy enterprise AlmaLinux workloads that scale globally! 🙌