Section 5 of 6
Azure App Service
🎯 What You'll Learn
- What is Azure App Service
- Creating App Service
- Deploying from Visual Studio
- Deploying from CLI
- Configuration settings
What is Azure App Service?
Azure App Service is a fully managed platform for hosting web applications, REST APIs, and mobile backends with built-in auto-scaling and load balancing.
Create App Service (Azure Portal)
- Go to Azure Portal
- Click Create a resource → Web App
- Fill in details:
- Name: inventtrack
- Runtime stack: .NET 8
- Region: Choose nearest
- Pricing tier: Choose plan
- Click Review + create
Deploy from Visual Studio
- Right-click project → Publish
- Select Azure → Next
- Select Azure App Service (Windows) → Next
- Sign in to Azure
- Select your App Service
- Click Finish
- Click Publish
Deploy from Azure CLI
Install Azure CLI
Bash
# Windows
winget install Microsoft.AzureCLI
# macOS
brew install azure-cli
# Linux
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
Login and Deploy
Bash
# Login
az login
# Create resource group
az group create --name InvenTrackRG --location eastus
# Create App Service plan
az appservice plan create --name InvenTrackPlan --resource-group InvenTrackRG --sku B1
# Create web app
az webapp create --name inventtrack --resource-group InvenTrackRG --plan InvenTrackPlan --runtime "DOTNET|8.0"
# Deploy
az webapp deployment source config-zip --resource-group InvenTrackRG --name inventtrack --src ./publish.zip
Configuration Settings
Application Settings
Azure Portal
Text
App Service → Configuration → Application settings
Add:
- ASPNETCORE_ENVIRONMENT = Production
- ConnectionStrings__DefaultConnection = [connection string]
Azure CLI
Bash
az webapp config appsettings set --resource-group InvenTrackRG --name inventtrack --settings ASPNETCORE_ENVIRONMENT=Production
Connection Strings
Azure CLI
Bash
az webapp config connection-string set --resource-group InvenTrackRG --name inventtrack --connection-string-type SQLAzure --settings DefaultConnection="Server=..."
Deployment Slots
Use slots for staging before production.
Create Staging Slot
Bash
az webapp deployment slot create --name inventtrack --resource-group InvenTrackRG --slot staging
Swap Slots
Bash
az webapp deployment slot swap --name inventtrack --resource-group InvenTrackRG --slot staging --target-slot production
Monitoring
- Application Insights: Performance monitoring
- Log Stream: Real-time logs
- Metrics: CPU, memory, requests
- Alerts: Notifications for issues
Key Takeaways
- Azure App Service: Fully managed hosting
- Visual Studio: Right-click publish
- Azure CLI: Command-line deployment
- Configuration: Application settings and connection strings
- Deployment slots: Staging before production
- Monitoring: Application Insights