Microsoft Azure provides a versatile cloud ecosystem for hosting web applications, balancing ease of use with powerful customization. Options include Azure Virtual Machines (VMs) for full control, Azure App Service for managed hosting, and Azure Functions for serverless execution. This document walks you through deploying a web app (e.g., a Python Flask app) on Azure from India, covering setup, deployment, and scaling as of February 20, 2025. Whether you’re a physics grad exploring tech or a seasoned dev, this guide gets your app online.
You’ll need:
An Azure account (sign up at azure.microsoft.com) with $200 free credit for 30 days.
Azure CLI installed (docs.microsoft.com/cli/azure).
A web app ready (e.g., Python Flask with app.py, requirements.txt).
Git installed for deployment
Step 1: Create a VM
Log into the Azure Portal, go to Virtual Machines > Create.
Configure:
Resource Group: web-rg (create new).
Name: web-vm.
Region: South India (for low latency).
Image: Ubuntu Server 22.04 LTS.
Size: B1s (free tier eligible).
Authentication: SSH public key (generate or use existing).
Under Networking, enable port 80 (HTTP).
Click Review + Create, then Create.
Step 2: Set Up the VM
SSH in:
ssh <username>@<public-ip>
Find the public IP in the VM’s Overview tab.
Update and install Python:
sudo apt update && sudo apt install -y python3-pip python3-venv
Step 3: Deploy Your App
Clone or upload your app:
git clone <your-repo> ~/web-app
cd ~/web-app
Set up a virtual environment:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Run the app:
python app.py
Example Flask app:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello from Azure!"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
Step 4: Keep It Running
Use gunicorn for production:
pip install gunicorn
gunicorn --bind 0.0.0.0:80 app:app
Add systemd service later for persistence.
Step 5: Test It
Visit http://<public-ip> in a browser.
Step 1: Create an App Service
In Azure Portal, go to App Services > Create.
Set up:
Resource Group: web-rg.
Name: mywebapp (unique, e.g., mywebapp123).
Runtime: Python 3.11.
Region: South India.
Pricing: Free F1 tier.
Click Review + Create, then Create.
Step 2: Deploy Your App
Install Azure CLI locally:
az login
Configure Git deployment:
az webapp deployment source config-local-git --name mywebapp --resource-group web-rg
Copy the returned Git URL (e.g.,https://<user>@mywebapp.scm.azurewebsites.net/mywebapp.git).
Push your app:
git remote add azure <git-url>
git push azure main
Ensure requirements.txt and app.py are in the repo root.
Step 3: Verify Deployment
Visit: https://mywebapp.azurewebsites.net.
Check logs:
az webapp log tail --name mywebapp --resource-group web-rg
Scaling
VM: Manually add VMs or use a load balancer (az vm create for more instances).
App Service: Upgrade to B1 tier (~$13/month) via Portal > Scale Up, or enable auto-scaling:
Scale Out > Add Rule > CPU > 70% > Increase by 1 instance.
Security
HTTPS: App Service provides free SSL (*.azurewebsites.net).
Firewall: For VM, adjust NSG rules in Networking tab (e.g., allow port 80 only).
Static Files
Use Azure Blob Storage:
az storage blob upload --account-name <storage-account> --container-name my-container --file image.jpg
Troubleshooting
VM: SSH fails? Check NSG rules or reboot via Portal.
App Service: Deployment stuck? Verify requirements.txt or runtime version.
404 Error: Ensure Flask app listens on port 80 or matches Azure’s expected port.
Cost Considerations
Free Tier: F1 App Service (60 CPU minutes/day) and B1s VM (limited usage) are free initially.
Paid: VM costs ~$13/month (B1s), App Service scales with usage. See Azure Pricing.
Azure offers flexible hosting options for web applications, from the hands on control of Virtual Machines to the streamlined ease of App Service. For a Python Flask app, App Service provides a quick, managed solution, while VMs suit custom needs all accessible from India with South India region support. With free tiers, robust scaling and built-in security, Azure empowers developers to deploy globally. Start with App Service for simplicity, then explore VMs or Azure Functions as your project evolves.
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.