Azure App Service - Deploying Web Applications
What is Azure App Service?
Azure App Service is a **fully managed platform-as-a-service (PaaS)** for hosting web applications, REST APIs, and backend services. It allows developers to deploy and scale web apps without managing infrastructure.
Why Use Azure App Service?
- Scalability: Auto-scale applications based on traffic.
- Multiple Languages: Supports .NET, Java, Python, Node.js, PHP.
- Integrated CI/CD: Deploy directly from GitHub, Azure DevOps.
- Security: Supports authentication via Azure AD, OAuth, and custom domains.
How to Create an Azure App Service (Step-by-Step)
Step 1: Login to Azure Portal
Go to Azure Portal and sign in.
Step 2: Create a Web App
Click on "Create a resource" → Select "App Service".
Step 3: Configure Basic Settings
- Subscription: Choose your Azure subscription.
- Resource Group: Create or select an existing group.
- App Name: Enter a unique name (e.g., mywebapp123).
- Runtime Stack: Choose .NET, Node.js, Python, Java, PHP.
- Region: Select the nearest Azure region.
Step 4: Choose Pricing Plan
For small projects, choose the **Free (F1) plan**, or for production, select **Standard (S1) or Premium (P1V2)**.
Step 5: Review and Create
Click "Review + Create" and wait for deployment.
Deploying an App to Azure App Service
1. Deploy Using GitHub Actions
Azure App Service integrates with GitHub Actions for automatic deployment.
name: Deploy to Azure App Service
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure App Service
uses: azure/webapps-deploy@v2
with:
app-name: "mywebapp123"
slot-name: "production"
package: .
2. Deploy Using Azure CLI
If you prefer manual deployment, use the Azure CLI:
az webapp up --name mywebapp123 --resource-group MyResourceGroup --runtime "PYTHON:3.8"
3. Deploy Using FTP
Azure App Service provides an FTP connection for manual uploads.
Scaling Azure App Service
Azure App Service supports both **manual scaling** and **auto-scaling**.
Manual Scaling
az webapp scale --resource-group MyResourceGroup --name mywebapp123 --instance-count 3
Auto-Scaling
Enable auto-scaling based on CPU usage.
Securing Azure App Service
- Use **Azure Application Gateway** for DDoS protection.
- Enable **HTTPS Only** in app settings.
- Use **Azure Key Vault** for storing sensitive configurations.
Cost Optimization Tips
- Use **Free Tier** for testing and development.
- Turn off apps when not in use.
- Use **Reserved Instances** for discounts.
Conclusion
Azure App Service is a powerful PaaS offering that makes deploying, scaling, and managing web applications seamless. With built-in CI/CD and security features, it is an ideal choice for hosting modern applications.
📌 Next Topic: Azure Blob Storage - Managing Files in the Cloud