Mid MVC

App Service automatically configures Kestrel + reverse proxy. ✅ Supports scaling, HTTPS, and monitoring out-of-the-box. 4⃣ How to Configure CI/CD Pipelines? Example with GitHub Actions: name: .NET Build & Deploy on: push: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' - name: Restore dependencies run: dotnet restore Follow : - name: Build run: dotnet build --configuration Release - name: Publish run: dotnet publish -c Release -o publish - name: Deploy to Azure uses: azure/webapps-deploy@v2 with: app-name: 'myapp' publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} package: ./publish ✅ Ensures automatic builds, tests, and deployment on code changes. 5⃣ How to Log in Production?

Logging in production should be:

  • Centralized
  • Structured
  • Persistent
  • Low-overhead

ASP.NET Core has ILogger interface and supports logging providers like Console, File,

Seq, Application Insights.

Example:

public class HomeController : Controller

private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger) => _logger

= logger;

Follow :

public IActionResult Index()

_logger.LogInformation("Index page visited at {Time}",

DateTime.UtcNow);

return View();

6⃣ What is Structured Logging?

Structured logging stores log data as key-value pairs instead of plain text.

Allows querying, filtering, and dashboards.

Example with Serilog:

Log.Logger = new LoggerConfiguration()

.Enrich.FromLogContext()

.WriteTo.Console()

.WriteTo.File("logs/log-.txt", rollingInterval:

RollingInterval.Day)

.CreateLogger();

Log Output:

"Timestamp": "2025-10-28T12:00:00Z",

"Level": "Information",

"Message": "Index page visited",

"Time": "2025-10-28T12:00:00Z"

✅ Makes filtering by user, requestId, or error type very easy.

7⃣ How to Use Serilog or NLog?

Follow :

Serilog Example (Program.cs):

builder.Host.UseSerilog((ctx, lc) => lc

.WriteTo.Console()

.WriteTo.File("logs/log-.txt", rollingInterval:

RollingInterval.Day)

NLog Example:

More from ASP.NET Core MVC Tutorial

All questions for this course