Azure
AzureIntermediate

Deploying Applications with Azure App Service

Technical Writer
4 min read
azureapp-serviceweb-appspaas

TL;DR

Learn how to deploy and manage web applications using Azure App Service. Covers deployment slots, scaling, monitoring, and continuous deployment.

Deploying Applications with Azure App Service

Azure App Service is a fully managed platform for building, deploying, and scaling web applications. This guide covers everything you need to know about using Azure App Service effectively.

$1

  • Multiple Language Support: .NET, Java, Node.js, Python, PHP
  • Built-in CI/CD: Integration with GitHub, Azure DevOps, and other sources
  • Auto-scaling: Horizontal and vertical scaling capabilities
  • Deployment Slots: Zero-downtime deployments
  • SSL/TLS Support: Managed certificates and custom domains
  • Authentication: Built-in authentication and authorization
  • $1

    $1

    ``bash

    Create a resource group

    az group create --name myResourceGroup --location eastus

    Create an App Service plan

    az appservice plan create \

    --name myAppServicePlan \

    --resource-group myResourceGroup \

    --sku B1 \

    --is-linux

    Create a web app

    az webapp create \

    --name myWebApp \

    --resource-group myResourceGroup \

    --plan myAppServicePlan \

    --runtime "NODE|14-lts"

    `

    $1

    `json

    {

    "appSettings": [

    {

    "name": "NODE_ENV",

    "value": "production"

    },

    {

    "name": "DATABASE_URL",

    "value": "your-connection-string"

    }

    ],

    "connectionStrings": [

    {

    "name": "MyDatabase",

    "type": "SQLAzure",

    "value": "Server=tcp:..."

    }

    ]

    }

    `

    $1

    $1

    `bash

    Create a deployment slot

    az webapp deployment slot create \

    --name myWebApp \

    --resource-group myResourceGroup \

    --slot staging

    Configure auto swap

    az webapp deployment slot auto-swap \

    --name myWebApp \

    --resource-group myResourceGroup \

    --slot staging

    `

    $1

    `json

    {

    "slotConfigNames": [

    "CONNECTION_STRING",

    "API_KEY"

    ],

    "stickySettings": {

    "appSettingNames": [

    "WEBSITE_NODE_DEFAULT_VERSION"

    ]

    }

    }

    `

    $1

    $1

    `json

    {

    "rules": [

    {

    "metricTrigger": {

    "metricName": "CpuPercentage",

    "metricResourceUri": "[resourceId('Microsoft.Web/serverfarms', 'myAppServicePlan')]",

    "timeGrain": "PT1M",

    "statistic": "Average",

    "timeWindow": "PT10M",

    "timeAggregation": "Average",

    "operator": "GreaterThan",

    "threshold": 70

    },

    "scaleAction": {

    "direction": "Increase",

    "type": "ChangeCount",

    "value": "1",

    "cooldown": "PT10M"

    }

    }

    ]

    }

    `

    $1

    $1

    `bash

    Enable Application Insights

    az webapp config appsettings set \

    --name myWebApp \

    --resource-group myResourceGroup \

    --settings APPINSIGHTS_INSTRUMENTATIONKEY=your-key

    Configure diagnostic settings

    az monitor diagnostic-settings create \

    --name myDiagnostics \

    --resource myWebApp \

    --logs "[{category: 'AppServiceHTTPLogs', enabled: true}]" \

    --metrics "[{category: 'AllMetrics', enabled: true}]"

    `

    $1

    1. Network Security

    - Enable App Service Authentication

    - Use Virtual Network Integration

    - Configure IP restrictions

    2. SSL/TLS Configuration

    - Enable HTTPS Only

    - Use TLS 1.2 or higher

    - Implement HSTS

    3. Access Control

    - Implement RBAC

    - Use Managed Identities

    - Regular key rotation

    $1

    $1

    `json

    {

    "caching": {

    "profiles": [

    {

    "name": "Default",

    "duration": "23:00:00",

    "location": "Any"

    }

    ],

    "rules": [

    {

    "path": "/*",

    "profile": "Default"

    }

    ]

    }

    }

    `

    $1

    $1

    `yaml

    name: Deploy to Azure App Service

    on:

    push:

    branches: [ main ]

    jobs:

    build-and-deploy:

    runs-on: ubuntu-latest

    steps:

    - uses: actions/checkout@v2

    - name: Set up Node.js

    uses: actions/setup-node@v2

    with:

    node-version: '14.x'

    - name: Install dependencies

    run: npm install

    - name: Build

    run: npm run build

    - name: Deploy to Azure

    uses: azure/webapps-deploy@v2

    with:

    app-name: 'myWebApp'

    publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

    package: .

    `

    $1

    1. Deployment Failures

    - Check deployment logs

    - Verify dependencies

    - Validate configuration settings

    2. Performance Issues

    - Monitor resource utilization

    - Check application logs

    - Analyze slow requests

    3. Connectivity Problems

    - Verify network configuration

    - Check SSL/TLS settings

    - Validate connection strings

    $1

    $1

    `bash

    Scale down during off-hours

    az webapp update \

    --name myWebApp \

    --resource-group myResourceGroup \

    --set numberOfWorkers=1

    Enable auto-shutdown

    az webapp config set \

    --name myWebApp \

    --resource-group myResourceGroup \

    --generic-configurations "{'autoShutdownEnabled': true, 'autoShutdownTime': '2200'}"

    ``

    $1

    Azure App Service provides a robust platform for hosting web applications with enterprise-grade features. By following this guide's best practices for deployment, security, and management, you can build and maintain scalable web applications efficiently.

    Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.