Overview
Ant Media Server can be deployed on Microsoft Azure using Azure Virtual Machines (VMs), Azure Marketplace one-click deployment, or Azure Virtual Machine Scale Sets (VMSS) for auto-scaling capabilities.
Deployment Methods
Azure Marketplace (Recommended)
Deploy Ant Media Server directly from Azure Marketplace:
Manual VM Deployment
Deploy on a standard Azure VM with custom configuration.
Azure Virtual Machine Scale Sets
Automated scaling using VMSS for high-traffic scenarios.
Virtual Machine Requirements
VM Sizes
Development/Testing:
- VM Size:
Standard_B2s or Standard_B2ms
- vCPUs: 2
- Memory: 4-8 GB
- Cost: ~$30-60/month
Production (Recommended):
- VM Size:
Standard_F4s_v2 or Standard_D4s_v3
- vCPUs: 4
- Memory: 8-16 GB
- Network: Accelerated Networking enabled
- Cost: ~$150-300/month
High-Performance Streaming:
- VM Size:
Standard_F8s_v2, Standard_D8s_v3
- vCPUs: 8-16
- Memory: 16-32 GB
- Network: Accelerated Networking (25 Gbps+)
- Premium SSD storage
- Cost: ~$300-600/month
Operating System Images
Supported Images:
- Ubuntu Server 20.04 LTS
- Ubuntu Server 22.04 LTS
- Debian 11
- Red Hat Enterprise Linux 8
- CentOS 8 Stream
Ubuntu 20.04 LTS or 22.04 LTS is recommended for optimal compatibility with Ant Media Server.
Storage
- OS Disk: 30 GB minimum (Premium SSD recommended)
- Data Disk: 100-500 GB for recordings (Premium SSD or Ultra Disk)
- Disk Type: Premium SSD for production workloads
Quick Start: Azure Marketplace Deployment
Access Azure Marketplace
- Log into Azure Portal (https://portal.azure.com)
- Search for “Ant Media Server” in the Marketplace
- Select Community or Enterprise Edition
- Click Create
Configure Basics
Fill in the basic configuration:
- Subscription: Select your Azure subscription
- Resource Group: Create new or select existing
- Region: Choose nearest region (e.g., East US, West Europe)
- VM Name: antmedia-server-01
- Authentication: SSH public key (recommended) or password
Configure VM Size
Select appropriate VM size:
- Click Change size
- Filter by compute-optimized (F-series) or general-purpose (D-series)
- Select
Standard_F4s_v2 or larger
- Enable Accelerated Networking if available
Configure Networking
Network settings:
- Virtual Network: Create new or select existing
- Subnet: Default or custom subnet
- Public IP: Create new static IP
- NIC Network Security Group: Advanced
- Configure NSG: Add inbound rules (see below)
Review and Create
- Review all settings
- Click Create
- Wait for deployment (5-10 minutes)
- Navigate to resource once complete
Access Web Panel
Get the public IP address:
- Go to Virtual Machine resource
- Copy Public IP address
- Open browser:
http://PUBLIC_IP:5080
- Create admin account on first access
Manual VM Deployment
Create Virtual Machine
Using Azure CLI:# Create resource group
az group create --name antmedia-rg --location eastus
# Create VM
az vm create \
--resource-group antmedia-rg \
--name antmedia-server \
--image Ubuntu2204 \
--size Standard_F4s_v2 \
--admin-username azureuser \
--ssh-key-values ~/.ssh/id_rsa.pub \
--public-ip-sku Standard \
--accelerated-networking true
Connect to VM
SSH into your VM:# Get public IP
IP=$(az vm show -d -g antmedia-rg -n antmedia-server --query publicIps -o tsv)
# Connect
ssh azureuser@$IP
Install Ant Media Server
Download and install:wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh
chmod +x install_ant-media-server.sh
sudo ./install_ant-media-server.sh
Configure Firewall
Open required ports in NSG (see section below)
Network Security Group (NSG) Configuration
Required Inbound Rules
Create NSG rules for required ports:
| Priority | Name | Port | Protocol | Source | Destination | Action |
|---|
| 100 | Allow-HTTP | 5080 | TCP | Any | Any | Allow |
| 110 | Allow-HTTPS | 5443 | TCP | Any | Any | Allow |
| 120 | Allow-RTMP | 1935 | TCP | Any | Any | Allow |
| 130 | Allow-RTMPS | 8443 | TCP | Any | Any | Allow |
| 140 | Allow-WebRTC | 5000-65000 | UDP | Any | Any | Allow |
| 200 | Allow-SSH | 22 | TCP | Your IP | Any | Allow |
Using Azure CLI
# Create NSG
az network nsg create \
--resource-group antmedia-rg \
--name antmedia-nsg
# Add rules
az network nsg rule create --resource-group antmedia-rg --nsg-name antmedia-nsg \
--name Allow-HTTP --priority 100 --source-address-prefixes '*' \
--destination-port-ranges 5080 --protocol Tcp --access Allow
az network nsg rule create --resource-group antmedia-rg --nsg-name antmedia-nsg \
--name Allow-HTTPS --priority 110 --source-address-prefixes '*' \
--destination-port-ranges 5443 --protocol Tcp --access Allow
az network nsg rule create --resource-group antmedia-rg --nsg-name antmedia-nsg \
--name Allow-RTMP --priority 120 --source-address-prefixes '*' \
--destination-port-ranges 1935 --protocol Tcp --access Allow
az network nsg rule create --resource-group antmedia-rg --nsg-name antmedia-nsg \
--name Allow-WebRTC --priority 140 --source-address-prefixes '*' \
--destination-port-ranges 5000-65000 --protocol Udp --access Allow
az network nsg rule create --resource-group antmedia-rg --nsg-name antmedia-nsg \
--name Allow-SSH --priority 200 --source-address-prefixes 'YOUR_IP' \
--destination-port-ranges 22 --protocol Tcp --access Allow
Restrict SSH (port 22) to specific IP addresses for security. Replace ‘YOUR_IP’ with your actual IP address.
Public IP Configuration
Create Static Public IP
# Create static public IP
az network public-ip create \
--resource-group antmedia-rg \
--name antmedia-public-ip \
--sku Standard \
--allocation-method Static
# Associate with VM
az network nic ip-config update \
--resource-group antmedia-rg \
--nic-name antmediaVMNic \
--name ipconfig1 \
--public-ip-address antmedia-public-ip
# Add DNS name
az network public-ip update \
--resource-group antmedia-rg \
--name antmedia-public-ip \
--dns-name antmedia-server
# Access via: antmedia-server.eastus.cloudapp.azure.com
Update Server Configuration
sudo nano /usr/local/antmedia/conf/red5.properties
Set your domain or public IP:
server.name=antmedia-server.eastus.cloudapp.azure.com
Restart:
sudo systemctl restart antmedia
Virtual Machine Scale Sets (Auto-Scaling)
Create VMSS with Azure CLI
# Create scale set
az vmss create \
--resource-group antmedia-rg \
--name antmedia-vmss \
--image Ubuntu2204 \
--vm-sku Standard_F4s_v2 \
--instance-count 2 \
--admin-username azureuser \
--ssh-key-values ~/.ssh/id_rsa.pub \
--public-ip-per-vm \
--load-balancer antmedia-lb \
--backend-pool-name antmedia-pool \
--upgrade-policy-mode Automatic
# Scale out when CPU > 75%
az monitor autoscale create \
--resource-group antmedia-rg \
--resource antmedia-vmss \
--resource-type Microsoft.Compute/virtualMachineScaleSets \
--name antmedia-autoscale \
--min-count 2 \
--max-count 10 \
--count 2
az monitor autoscale rule create \
--resource-group antmedia-rg \
--autoscale-name antmedia-autoscale \
--condition "Percentage CPU > 75 avg 5m" \
--scale out 2
# Scale in when CPU < 30%
az monitor autoscale rule create \
--resource-group antmedia-rg \
--autoscale-name antmedia-autoscale \
--condition "Percentage CPU < 30 avg 5m" \
--scale in 1
Custom Script Extension
Automate Ant Media Server installation on VMSS:
az vmss extension set \
--resource-group antmedia-rg \
--vmss-name antmedia-vmss \
--name CustomScript \
--publisher Microsoft.Azure.Extensions \
--version 2.1 \
--settings '{"fileUris": ["https://raw.githubusercontent.com/ant-media/Scripts/master/install_ant-media-server.sh"], "commandToExecute": "bash install_ant-media-server.sh"}'
Load Balancer Configuration
Create Application Gateway
For advanced load balancing with SSL termination:
# Create Application Gateway
az network application-gateway create \
--name antmedia-appgw \
--resource-group antmedia-rg \
--location eastus \
--sku Standard_v2 \
--public-ip-address antmedia-gateway-ip \
--vnet-name antmedia-vnet \
--subnet gateway-subnet \
--capacity 2 \
--http-settings-cookie-based-affinity Disabled \
--http-settings-port 5080 \
--http-settings-protocol Http \
--frontend-port 80
Health Probe Configuration
Configure health probes for backend pool:
az network application-gateway probe create \
--gateway-name antmedia-appgw \
--resource-group antmedia-rg \
--name antmedia-health \
--protocol Http \
--host-name-from-http-settings true \
--match-status-codes 200-399 \
--path / \
--interval 30 \
--timeout 30 \
--threshold 3
Storage Configuration
Attach Managed Disk
# Create managed disk
az disk create \
--resource-group antmedia-rg \
--name antmedia-data-disk \
--size-gb 100 \
--sku Premium_LRS
# Attach to VM
az vm disk attach \
--resource-group antmedia-rg \
--vm-name antmedia-server \
--name antmedia-data-disk
Mount the disk:
# Inside VM
sudo fdisk -l
sudo mkfs -t ext4 /dev/sdc
sudo mkdir -p /mnt/streams
sudo mount /dev/sdc /mnt/streams
echo '/dev/sdc /mnt/streams ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab
sudo chown -R antmedia:antmedia /mnt/streams
Azure Blob Storage Integration
Configure blob storage for recordings:
# Create storage account
az storage account create \
--name antmediastorage \
--resource-group antmedia-rg \
--location eastus \
--sku Standard_LRS
# Create container
az storage container create \
--name recordings \
--account-name antmediastorage \
--public-access off
# Get connection string
az storage account show-connection-string \
--name antmediastorage \
--resource-group antmedia-rg
Configure in application settings via web panel.
Database Configuration (Enterprise)
Azure Cosmos DB (MongoDB API)
# Create Cosmos DB account
az cosmosdb create \
--name antmedia-cosmos \
--resource-group antmedia-rg \
--kind MongoDB \
--server-version 4.2 \
--default-consistency-level Session
# Create database
az cosmosdb mongodb database create \
--account-name antmedia-cosmos \
--resource-group antmedia-rg \
--name antmedia
# Get connection string
az cosmosdb keys list \
--name antmedia-cosmos \
--resource-group antmedia-rg \
--type connection-strings
sudo /usr/local/antmedia/change_server_mode.sh cluster "mongodb://antmedia-cosmos:[email protected]:10255/?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000"
SSL/TLS Configuration
Using Application Gateway with SSL
- Upload SSL certificate to Azure Key Vault
- Configure Application Gateway listener with certificate
- Set up HTTP to HTTPS redirect
Using Let’s Encrypt on VM
Monitoring with Azure Monitor
Enable VM Insights
az vm extension set \
--resource-group antmedia-rg \
--vm-name antmedia-server \
--name AzureMonitorLinuxAgent \
--publisher Microsoft.Azure.Monitor \
--enable-auto-upgrade true
Create Alerts
# CPU alert
az monitor metrics alert create \
--name HighCPU \
--resource-group antmedia-rg \
--scopes /subscriptions/SUB_ID/resourceGroups/antmedia-rg/providers/Microsoft.Compute/virtualMachines/antmedia-server \
--condition "avg Percentage CPU > 80" \
--window-size 5m \
--evaluation-frequency 1m
Backup and Disaster Recovery
Azure Backup
# Create Recovery Services vault
az backup vault create \
--resource-group antmedia-rg \
--name antmedia-vault \
--location eastus
# Enable backup for VM
az backup protection enable-for-vm \
--resource-group antmedia-rg \
--vault-name antmedia-vault \
--vm antmedia-server \
--policy-name DefaultPolicy
Snapshot-based Backup
# Create disk snapshot
az snapshot create \
--resource-group antmedia-rg \
--name antmedia-snapshot-$(date +%Y%m%d) \
--source antmedia-server_OsDisk_1
Cost Optimization
Reserved Instances
Purchase Azure Reserved VM Instances for up to 72% savings on production workloads.
Auto-Shutdown Schedule
az vm auto-shutdown \
--resource-group antmedia-rg \
--name antmedia-server \
--time 2300 \
--timezone "Eastern Standard Time"
Spot Instances
For non-critical workloads:
az vm create \
--resource-group antmedia-rg \
--name antmedia-spot \
--image Ubuntu2204 \
--size Standard_F4s_v2 \
--priority Spot \
--max-price -1 \
--eviction-policy Deallocate
Troubleshooting
VM Not Accessible
- Check NSG rules in Azure Portal
- Verify VM is running
- Check public IP association
- Review boot diagnostics logs
- Check Azure Monitor metrics
- Verify accelerated networking is enabled
- Check disk IOPS and throughput
- Review application logs
WebRTC Connection Issues
- Verify UDP ports 5000-65000 in NSG
- Check public IP configuration
- Ensure server.name is correctly set
- Test with STUN servers
Next Steps