Isaac.

Azure App Service with ASP.NET Core

Deploy and manage ASP.NET Core applications on Azure App Service.

By EMEPublished: February 20, 2025
azureapp serviceaspnet coredeploymentpaas

A Simple Analogy

Azure App Service is like renting a house instead of building one. You don't manage the foundation (servers, OS, runtime)—Azure handles that. You just run your app and pay for what you use.


What Is Azure App Service?

App Service is a Platform-as-a-Service (PaaS) for hosting web apps, APIs, and mobile backends. It handles infrastructure, scaling, and patching automatically.


Benefits

  • No infrastructure management: Focus on code
  • Auto-scaling: Handle traffic spikes automatically
  • Built-in CI/CD: Deploy from GitHub, Azure DevOps
  • Monitoring: Application Insights integration
  • Cost-effective: Pay-as-you-go pricing

Deployment from .NET Project

// In Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
builder.Services.AddApplicationInsightsTelemetry();

var app = builder.Build();
app.UseHttpsRedirection();
app.MapControllers();
app.Run();

Deploy with Azure CLI:

az webapp create --resource-group myGroup \
  --plan myServicePlan \
  --name myApp
  
dotnet publish -c Release
az webapp deployment source config-zip \
  --resource-group myGroup \
  --name myApp \
  --src publish.zip

Configuration & Secrets

// Access App Service settings
var connectionString = builder.Configuration["ConnectionStrings:Default"];
var apiKey = builder.Configuration["ApiKey"];

// From Azure Key Vault
builder.Configuration.AddAzureKeyVault(
    new Uri($"https://{keyVaultName}.vault.azure.net/"),
    new DefaultAzureCredential());

Scaling

# Scale up (increase machine size)
az appservice plan update --name myPlan \
  --resource-group myGroup \
  --sku P1V2

# Scale out (add instances)
az appservice plan update --name myPlan \
  --resource-group myGroup \
  --number-of-workers 3

Monitoring

public class HealthCheckController : ControllerBase
{
    [HttpGet("/health")]
    public IActionResult Health()
    {
        return Ok(new { status = "healthy" });
    }
}

// App Service can use this for health checks

Best Practices

  1. Use deployment slots: Test before production
  2. Enable authentication: Azure AD integration
  3. Monitor performance: Application Insights
  4. Auto-scale rules: Scale based on CPU/memory
  5. Database connections: Use Connection Strings

Related Concepts

  • Application Insights monitoring
  • Deployment slots for staging
  • Azure SQL Database integration
  • Application gateway for load balancing

Summary

Azure App Service simplifies ASP.NET Core deployment with automatic scaling, monitoring, and built-in DevOps. Focus on building features while Azure handles infrastructure.